documentation.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216
  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. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  496. */
  497. export class PerformanceMonitor {
  498. private _enabled;
  499. private _rollingFrameTime;
  500. private _lastFrameTimeMs;
  501. /**
  502. * constructor
  503. * @param frameSampleSize The number of samples required to saturate the sliding window
  504. */
  505. constructor(frameSampleSize?: number);
  506. /**
  507. * Samples current frame
  508. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  509. */
  510. sampleFrame(timeMs?: number): void;
  511. /**
  512. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  513. */
  514. readonly averageFrameTime: number;
  515. /**
  516. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  517. */
  518. readonly averageFrameTimeVariance: number;
  519. /**
  520. * Returns the frame time of the most recent frame
  521. */
  522. readonly instantaneousFrameTime: number;
  523. /**
  524. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  525. */
  526. readonly averageFPS: number;
  527. /**
  528. * Returns the average framerate in frames per second using the most recent frame time
  529. */
  530. readonly instantaneousFPS: number;
  531. /**
  532. * Returns true if enough samples have been taken to completely fill the sliding window
  533. */
  534. readonly isSaturated: boolean;
  535. /**
  536. * Enables contributions to the sliding window sample set
  537. */
  538. enable(): void;
  539. /**
  540. * Disables contributions to the sliding window sample set
  541. * Samples will not be interpolated over the disabled period
  542. */
  543. disable(): void;
  544. /**
  545. * Returns true if sampling is enabled
  546. */
  547. readonly isEnabled: boolean;
  548. /**
  549. * Resets performance monitor
  550. */
  551. reset(): void;
  552. }
  553. /**
  554. * RollingAverage
  555. *
  556. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  557. */
  558. export class RollingAverage {
  559. /**
  560. * Current average
  561. */
  562. average: number;
  563. /**
  564. * Current variance
  565. */
  566. variance: number;
  567. protected _samples: Array<number>;
  568. protected _sampleCount: number;
  569. protected _pos: number;
  570. protected _m2: number;
  571. /**
  572. * constructor
  573. * @param length The number of samples required to saturate the sliding window
  574. */
  575. constructor(length: number);
  576. /**
  577. * Adds a sample to the sample set
  578. * @param v The sample value
  579. */
  580. add(v: number): void;
  581. /**
  582. * Returns previously added values or null if outside of history or outside the sliding window domain
  583. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  584. * @return Value previously recorded with add() or null if outside of range
  585. */
  586. history(i: number): number;
  587. /**
  588. * Returns true if enough samples have been taken to completely fill the sliding window
  589. * @return true if sample-set saturated
  590. */
  591. isSaturated(): boolean;
  592. /**
  593. * Resets the rolling average (equivalent to 0 samples taken so far)
  594. */
  595. reset(): void;
  596. /**
  597. * Wraps a value around the sample range boundaries
  598. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  599. * @return Wrapped position in sample range
  600. */
  601. protected _wrapPosition(i: number): number;
  602. }
  603. }
  604. declare module BABYLON {
  605. /**
  606. * This class implement a typical dictionary using a string as key and the generic type T as value.
  607. * The underlying implementation relies on an associative array to ensure the best performances.
  608. * The value can be anything including 'null' but except 'undefined'
  609. */
  610. export class StringDictionary<T> {
  611. /**
  612. * This will clear this dictionary and copy the content from the 'source' one.
  613. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  614. * @param source the dictionary to take the content from and copy to this dictionary
  615. */
  616. copyFrom(source: StringDictionary<T>): void;
  617. /**
  618. * Get a value based from its key
  619. * @param key the given key to get the matching value from
  620. * @return the value if found, otherwise undefined is returned
  621. */
  622. get(key: string): T | undefined;
  623. /**
  624. * Get a value from its key or add it if it doesn't exist.
  625. * This method will ensure you that a given key/data will be present in the dictionary.
  626. * @param key the given key to get the matching value from
  627. * @param factory the factory that will create the value if the key is not present in the dictionary.
  628. * The factory will only be invoked if there's no data for the given key.
  629. * @return the value corresponding to the key.
  630. */
  631. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  632. /**
  633. * Get a value from its key if present in the dictionary otherwise add it
  634. * @param key the key to get the value from
  635. * @param val if there's no such key/value pair in the dictionary add it with this value
  636. * @return the value corresponding to the key
  637. */
  638. getOrAdd(key: string, val: T): T;
  639. /**
  640. * Check if there's a given key in the dictionary
  641. * @param key the key to check for
  642. * @return true if the key is present, false otherwise
  643. */
  644. contains(key: string): boolean;
  645. /**
  646. * Add a new key and its corresponding value
  647. * @param key the key to add
  648. * @param value the value corresponding to the key
  649. * @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
  650. */
  651. add(key: string, value: T): boolean;
  652. /**
  653. * Update a specific value associated to a key
  654. * @param key defines the key to use
  655. * @param value defines the value to store
  656. * @returns true if the value was updated (or false if the key was not found)
  657. */
  658. set(key: string, value: T): boolean;
  659. /**
  660. * Get the element of the given key and remove it from the dictionary
  661. * @param key defines the key to search
  662. * @returns the value associated with the key or null if not found
  663. */
  664. getAndRemove(key: string): Nullable<T>;
  665. /**
  666. * Remove a key/value from the dictionary.
  667. * @param key the key to remove
  668. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  669. */
  670. remove(key: string): boolean;
  671. /**
  672. * Clear the whole content of the dictionary
  673. */
  674. clear(): void;
  675. /**
  676. * Gets the current count
  677. */
  678. readonly count: number;
  679. /**
  680. * Execute a callback on each key/val of the dictionary.
  681. * Note that you can remove any element in this dictionary in the callback implementation
  682. * @param callback the callback to execute on a given key/value pair
  683. */
  684. forEach(callback: (key: string, val: T) => void): void;
  685. /**
  686. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  687. * If the callback returns null or undefined the method will iterate to the next key/value pair
  688. * Note that you can remove any element in this dictionary in the callback implementation
  689. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  690. * @returns the first item
  691. */
  692. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  693. private _count;
  694. private _data;
  695. }
  696. }
  697. declare module BABYLON {
  698. /**
  699. * Class used to store gfx data (like WebGLBuffer)
  700. */
  701. export class DataBuffer {
  702. /**
  703. * Gets or sets the number of objects referencing this buffer
  704. */
  705. references: number;
  706. /** Gets or sets the size of the underlying buffer */
  707. capacity: number;
  708. /**
  709. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  710. */
  711. is32Bits: boolean;
  712. /**
  713. * Gets the underlying buffer
  714. */
  715. readonly underlyingResource: any;
  716. }
  717. }
  718. declare module BABYLON {
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module BABYLON {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. }
  1248. declare module BABYLON {
  1249. /**
  1250. * Class used to represent a viewport on screen
  1251. */
  1252. export class Viewport {
  1253. /** viewport left coordinate */
  1254. x: number;
  1255. /** viewport top coordinate */
  1256. y: number;
  1257. /**viewport width */
  1258. width: number;
  1259. /** viewport height */
  1260. height: number;
  1261. /**
  1262. * Creates a Viewport object located at (x, y) and sized (width, height)
  1263. * @param x defines viewport left coordinate
  1264. * @param y defines viewport top coordinate
  1265. * @param width defines the viewport width
  1266. * @param height defines the viewport height
  1267. */
  1268. constructor(
  1269. /** viewport left coordinate */
  1270. x: number,
  1271. /** viewport top coordinate */
  1272. y: number,
  1273. /**viewport width */
  1274. width: number,
  1275. /** viewport height */
  1276. height: number);
  1277. /**
  1278. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1279. * @param renderWidth defines the rendering width
  1280. * @param renderHeight defines the rendering height
  1281. * @returns a new Viewport
  1282. */
  1283. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1284. /**
  1285. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1286. * @param renderWidth defines the rendering width
  1287. * @param renderHeight defines the rendering height
  1288. * @param ref defines the target viewport
  1289. * @returns the current viewport
  1290. */
  1291. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1292. /**
  1293. * Returns a new Viewport copied from the current one
  1294. * @returns a new Viewport
  1295. */
  1296. clone(): Viewport;
  1297. }
  1298. }
  1299. declare module BABYLON {
  1300. /**
  1301. * Class containing a set of static utilities functions for arrays.
  1302. */
  1303. export class ArrayTools {
  1304. /**
  1305. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1306. * @param size the number of element to construct and put in the array
  1307. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1308. * @returns a new array filled with new objects
  1309. */
  1310. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1311. }
  1312. }
  1313. declare module BABYLON {
  1314. /**
  1315. * @hidden
  1316. */
  1317. export interface IColor4Like {
  1318. r: float;
  1319. g: float;
  1320. b: float;
  1321. a: float;
  1322. }
  1323. /**
  1324. * @hidden
  1325. */
  1326. export interface IColor3Like {
  1327. r: float;
  1328. g: float;
  1329. b: float;
  1330. }
  1331. /**
  1332. * @hidden
  1333. */
  1334. export interface IVector4Like {
  1335. x: float;
  1336. y: float;
  1337. z: float;
  1338. w: float;
  1339. }
  1340. /**
  1341. * @hidden
  1342. */
  1343. export interface IVector3Like {
  1344. x: float;
  1345. y: float;
  1346. z: float;
  1347. }
  1348. /**
  1349. * @hidden
  1350. */
  1351. export interface IVector2Like {
  1352. x: float;
  1353. y: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IMatrixLike {
  1359. toArray(): DeepImmutable<Float32Array>;
  1360. updateFlag: int;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IViewportLike {
  1366. x: float;
  1367. y: float;
  1368. width: float;
  1369. height: float;
  1370. }
  1371. /**
  1372. * @hidden
  1373. */
  1374. export interface IPlaneLike {
  1375. normal: IVector3Like;
  1376. d: float;
  1377. normalize(): void;
  1378. }
  1379. }
  1380. declare module BABYLON {
  1381. /**
  1382. * Class representing a vector containing 2 coordinates
  1383. */
  1384. export class Vector2 {
  1385. /** defines the first coordinate */
  1386. x: number;
  1387. /** defines the second coordinate */
  1388. y: number;
  1389. /**
  1390. * Creates a new Vector2 from the given x and y coordinates
  1391. * @param x defines the first coordinate
  1392. * @param y defines the second coordinate
  1393. */
  1394. constructor(
  1395. /** defines the first coordinate */
  1396. x?: number,
  1397. /** defines the second coordinate */
  1398. y?: number);
  1399. /**
  1400. * Gets a string with the Vector2 coordinates
  1401. * @returns a string with the Vector2 coordinates
  1402. */
  1403. toString(): string;
  1404. /**
  1405. * Gets class name
  1406. * @returns the string "Vector2"
  1407. */
  1408. getClassName(): string;
  1409. /**
  1410. * Gets current vector hash code
  1411. * @returns the Vector2 hash code as a number
  1412. */
  1413. getHashCode(): number;
  1414. /**
  1415. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1416. * @param array defines the source array
  1417. * @param index defines the offset in source array
  1418. * @returns the current Vector2
  1419. */
  1420. toArray(array: FloatArray, index?: number): Vector2;
  1421. /**
  1422. * Copy the current vector to an array
  1423. * @returns a new array with 2 elements: the Vector2 coordinates.
  1424. */
  1425. asArray(): number[];
  1426. /**
  1427. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1428. * @param source defines the source Vector2
  1429. * @returns the current updated Vector2
  1430. */
  1431. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1432. /**
  1433. * Sets the Vector2 coordinates with the given floats
  1434. * @param x defines the first coordinate
  1435. * @param y defines the second coordinate
  1436. * @returns the current updated Vector2
  1437. */
  1438. copyFromFloats(x: number, y: number): Vector2;
  1439. /**
  1440. * Sets the Vector2 coordinates with the given floats
  1441. * @param x defines the first coordinate
  1442. * @param y defines the second coordinate
  1443. * @returns the current updated Vector2
  1444. */
  1445. set(x: number, y: number): Vector2;
  1446. /**
  1447. * Add another vector with the current one
  1448. * @param otherVector defines the other vector
  1449. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1450. */
  1451. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1452. /**
  1453. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1454. * @param otherVector defines the other vector
  1455. * @param result defines the target vector
  1456. * @returns the unmodified current Vector2
  1457. */
  1458. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1459. /**
  1460. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1461. * @param otherVector defines the other vector
  1462. * @returns the current updated Vector2
  1463. */
  1464. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1465. /**
  1466. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1467. * @param otherVector defines the other vector
  1468. * @returns a new Vector2
  1469. */
  1470. addVector3(otherVector: Vector3): Vector2;
  1471. /**
  1472. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1473. * @param otherVector defines the other vector
  1474. * @returns a new Vector2
  1475. */
  1476. subtract(otherVector: Vector2): Vector2;
  1477. /**
  1478. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1479. * @param otherVector defines the other vector
  1480. * @param result defines the target vector
  1481. * @returns the unmodified current Vector2
  1482. */
  1483. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1484. /**
  1485. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1486. * @param otherVector defines the other vector
  1487. * @returns the current updated Vector2
  1488. */
  1489. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1490. /**
  1491. * Multiplies in place the current Vector2 coordinates by the given ones
  1492. * @param otherVector defines the other vector
  1493. * @returns the current updated Vector2
  1494. */
  1495. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1498. * @param otherVector defines the other vector
  1499. * @returns a new Vector2
  1500. */
  1501. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1502. /**
  1503. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1504. * @param otherVector defines the other vector
  1505. * @param result defines the target vector
  1506. * @returns the unmodified current Vector2
  1507. */
  1508. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1509. /**
  1510. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1511. * @param x defines the first coordinate
  1512. * @param y defines the second coordinate
  1513. * @returns a new Vector2
  1514. */
  1515. multiplyByFloats(x: number, y: number): Vector2;
  1516. /**
  1517. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1518. * @param otherVector defines the other vector
  1519. * @returns a new Vector2
  1520. */
  1521. divide(otherVector: Vector2): Vector2;
  1522. /**
  1523. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1524. * @param otherVector defines the other vector
  1525. * @param result defines the target vector
  1526. * @returns the unmodified current Vector2
  1527. */
  1528. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1529. /**
  1530. * Divides the current Vector2 coordinates by the given ones
  1531. * @param otherVector defines the other vector
  1532. * @returns the current updated Vector2
  1533. */
  1534. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1535. /**
  1536. * Gets a new Vector2 with current Vector2 negated coordinates
  1537. * @returns a new Vector2
  1538. */
  1539. negate(): Vector2;
  1540. /**
  1541. * Multiply the Vector2 coordinates by scale
  1542. * @param scale defines the scaling factor
  1543. * @returns the current updated Vector2
  1544. */
  1545. scaleInPlace(scale: number): Vector2;
  1546. /**
  1547. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1548. * @param scale defines the scaling factor
  1549. * @returns a new Vector2
  1550. */
  1551. scale(scale: number): Vector2;
  1552. /**
  1553. * Scale the current Vector2 values by a factor to a given Vector2
  1554. * @param scale defines the scale factor
  1555. * @param result defines the Vector2 object where to store the result
  1556. * @returns the unmodified current Vector2
  1557. */
  1558. scaleToRef(scale: number, result: Vector2): Vector2;
  1559. /**
  1560. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1561. * @param scale defines the scale factor
  1562. * @param result defines the Vector2 object where to store the result
  1563. * @returns the unmodified current Vector2
  1564. */
  1565. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1566. /**
  1567. * Gets a boolean if two vectors are equals
  1568. * @param otherVector defines the other vector
  1569. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1570. */
  1571. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1572. /**
  1573. * Gets a boolean if two vectors are equals (using an epsilon value)
  1574. * @param otherVector defines the other vector
  1575. * @param epsilon defines the minimal distance to consider equality
  1576. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1577. */
  1578. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. floor(): Vector2;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. fract(): Vector2;
  1589. /**
  1590. * Gets the length of the vector
  1591. * @returns the vector length (float)
  1592. */
  1593. length(): number;
  1594. /**
  1595. * Gets the vector squared length
  1596. * @returns the vector squared length (float)
  1597. */
  1598. lengthSquared(): number;
  1599. /**
  1600. * Normalize the vector
  1601. * @returns the current updated Vector2
  1602. */
  1603. normalize(): Vector2;
  1604. /**
  1605. * Gets a new Vector2 copied from the Vector2
  1606. * @returns a new Vector2
  1607. */
  1608. clone(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(0, 0)
  1611. * @returns a new Vector2
  1612. */
  1613. static Zero(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(1, 1)
  1616. * @returns a new Vector2
  1617. */
  1618. static One(): Vector2;
  1619. /**
  1620. * Gets a new Vector2 set from the given index element of the given array
  1621. * @param array defines the data source
  1622. * @param offset defines the offset in the data source
  1623. * @returns a new Vector2
  1624. */
  1625. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1626. /**
  1627. * Sets "result" from the given index element of the given array
  1628. * @param array defines the data source
  1629. * @param offset defines the offset in the data source
  1630. * @param result defines the target vector
  1631. */
  1632. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1633. /**
  1634. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1635. * @param value1 defines 1st point of control
  1636. * @param value2 defines 2nd point of control
  1637. * @param value3 defines 3rd point of control
  1638. * @param value4 defines 4th point of control
  1639. * @param amount defines the interpolation factor
  1640. * @returns a new Vector2
  1641. */
  1642. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1643. /**
  1644. * 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".
  1645. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1646. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1647. * @param value defines the value to clamp
  1648. * @param min defines the lower limit
  1649. * @param max defines the upper limit
  1650. * @returns a new Vector2
  1651. */
  1652. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1655. * @param value1 defines the 1st control point
  1656. * @param tangent1 defines the outgoing tangent
  1657. * @param value2 defines the 2nd control point
  1658. * @param tangent2 defines the incoming tangent
  1659. * @param amount defines the interpolation factor
  1660. * @returns a new Vector2
  1661. */
  1662. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1665. * @param start defines the start vector
  1666. * @param end defines the end vector
  1667. * @param amount defines the interpolation factor
  1668. * @returns a new Vector2
  1669. */
  1670. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1671. /**
  1672. * Gets the dot product of the vector "left" and the vector "right"
  1673. * @param left defines first vector
  1674. * @param right defines second vector
  1675. * @returns the dot product (float)
  1676. */
  1677. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1678. /**
  1679. * Returns a new Vector2 equal to the normalized given vector
  1680. * @param vector defines the vector to normalize
  1681. * @returns a new Vector2
  1682. */
  1683. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1684. /**
  1685. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1686. * @param left defines 1st vector
  1687. * @param right defines 2nd vector
  1688. * @returns a new Vector2
  1689. */
  1690. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1691. /**
  1692. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1693. * @param left defines 1st vector
  1694. * @param right defines 2nd vector
  1695. * @returns a new Vector2
  1696. */
  1697. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1698. /**
  1699. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1700. * @param vector defines the vector to transform
  1701. * @param transformation defines the matrix to apply
  1702. * @returns a new Vector2
  1703. */
  1704. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1705. /**
  1706. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1707. * @param vector defines the vector to transform
  1708. * @param transformation defines the matrix to apply
  1709. * @param result defines the target vector
  1710. */
  1711. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1712. /**
  1713. * Determines if a given vector is included in a triangle
  1714. * @param p defines the vector to test
  1715. * @param p0 defines 1st triangle point
  1716. * @param p1 defines 2nd triangle point
  1717. * @param p2 defines 3rd triangle point
  1718. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1719. */
  1720. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1721. /**
  1722. * Gets the distance between the vectors "value1" and "value2"
  1723. * @param value1 defines first vector
  1724. * @param value2 defines second vector
  1725. * @returns the distance between vectors
  1726. */
  1727. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1728. /**
  1729. * Returns the squared distance between the vectors "value1" and "value2"
  1730. * @param value1 defines first vector
  1731. * @param value2 defines second vector
  1732. * @returns the squared distance between vectors
  1733. */
  1734. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1735. /**
  1736. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1737. * @param value1 defines first vector
  1738. * @param value2 defines second vector
  1739. * @returns a new Vector2
  1740. */
  1741. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1742. /**
  1743. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1744. * @param p defines the middle point
  1745. * @param segA defines one point of the segment
  1746. * @param segB defines the other point of the segment
  1747. * @returns the shortest distance
  1748. */
  1749. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1750. }
  1751. /**
  1752. * Classed used to store (x,y,z) vector representation
  1753. * A Vector3 is the main object used in 3D geometry
  1754. * It can represent etiher the coordinates of a point the space, either a direction
  1755. * Reminder: js uses a left handed forward facing system
  1756. */
  1757. export class Vector3 {
  1758. /**
  1759. * Defines the first coordinates (on X axis)
  1760. */
  1761. x: number;
  1762. /**
  1763. * Defines the second coordinates (on Y axis)
  1764. */
  1765. y: number;
  1766. /**
  1767. * Defines the third coordinates (on Z axis)
  1768. */
  1769. z: number;
  1770. private static _UpReadOnly;
  1771. private static _ZeroReadOnly;
  1772. /**
  1773. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1774. * @param x defines the first coordinates (on X axis)
  1775. * @param y defines the second coordinates (on Y axis)
  1776. * @param z defines the third coordinates (on Z axis)
  1777. */
  1778. constructor(
  1779. /**
  1780. * Defines the first coordinates (on X axis)
  1781. */
  1782. x?: number,
  1783. /**
  1784. * Defines the second coordinates (on Y axis)
  1785. */
  1786. y?: number,
  1787. /**
  1788. * Defines the third coordinates (on Z axis)
  1789. */
  1790. z?: number);
  1791. /**
  1792. * Creates a string representation of the Vector3
  1793. * @returns a string with the Vector3 coordinates.
  1794. */
  1795. toString(): string;
  1796. /**
  1797. * Gets the class name
  1798. * @returns the string "Vector3"
  1799. */
  1800. getClassName(): string;
  1801. /**
  1802. * Creates the Vector3 hash code
  1803. * @returns a number which tends to be unique between Vector3 instances
  1804. */
  1805. getHashCode(): number;
  1806. /**
  1807. * Creates an array containing three elements : the coordinates of the Vector3
  1808. * @returns a new array of numbers
  1809. */
  1810. asArray(): number[];
  1811. /**
  1812. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1813. * @param array defines the destination array
  1814. * @param index defines the offset in the destination array
  1815. * @returns the current Vector3
  1816. */
  1817. toArray(array: FloatArray, index?: number): Vector3;
  1818. /**
  1819. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1820. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1821. */
  1822. toQuaternion(): Quaternion;
  1823. /**
  1824. * Adds the given vector to the current Vector3
  1825. * @param otherVector defines the second operand
  1826. * @returns the current updated Vector3
  1827. */
  1828. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1829. /**
  1830. * Adds the given coordinates to the current Vector3
  1831. * @param x defines the x coordinate of the operand
  1832. * @param y defines the y coordinate of the operand
  1833. * @param z defines the z coordinate of the operand
  1834. * @returns the current updated Vector3
  1835. */
  1836. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1837. /**
  1838. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1839. * @param otherVector defines the second operand
  1840. * @returns the resulting Vector3
  1841. */
  1842. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1845. * @param otherVector defines the second operand
  1846. * @param result defines the Vector3 object where to store the result
  1847. * @returns the current Vector3
  1848. */
  1849. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1850. /**
  1851. * Subtract the given vector from the current Vector3
  1852. * @param otherVector defines the second operand
  1853. * @returns the current updated Vector3
  1854. */
  1855. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1856. /**
  1857. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1858. * @param otherVector defines the second operand
  1859. * @returns the resulting Vector3
  1860. */
  1861. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1862. /**
  1863. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1864. * @param otherVector defines the second operand
  1865. * @param result defines the Vector3 object where to store the result
  1866. * @returns the current Vector3
  1867. */
  1868. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1869. /**
  1870. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1871. * @param x defines the x coordinate of the operand
  1872. * @param y defines the y coordinate of the operand
  1873. * @param z defines the z coordinate of the operand
  1874. * @returns the resulting Vector3
  1875. */
  1876. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1877. /**
  1878. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1879. * @param x defines the x coordinate of the operand
  1880. * @param y defines the y coordinate of the operand
  1881. * @param z defines the z coordinate of the operand
  1882. * @param result defines the Vector3 object where to store the result
  1883. * @returns the current Vector3
  1884. */
  1885. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1886. /**
  1887. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1888. * @returns a new Vector3
  1889. */
  1890. negate(): Vector3;
  1891. /**
  1892. * Multiplies the Vector3 coordinates by the float "scale"
  1893. * @param scale defines the multiplier factor
  1894. * @returns the current updated Vector3
  1895. */
  1896. scaleInPlace(scale: number): Vector3;
  1897. /**
  1898. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1899. * @param scale defines the multiplier factor
  1900. * @returns a new Vector3
  1901. */
  1902. scale(scale: number): Vector3;
  1903. /**
  1904. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1905. * @param scale defines the multiplier factor
  1906. * @param result defines the Vector3 object where to store the result
  1907. * @returns the current Vector3
  1908. */
  1909. scaleToRef(scale: number, result: Vector3): Vector3;
  1910. /**
  1911. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1912. * @param scale defines the scale factor
  1913. * @param result defines the Vector3 object where to store the result
  1914. * @returns the unmodified current Vector3
  1915. */
  1916. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1917. /**
  1918. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1919. * @param otherVector defines the second operand
  1920. * @returns true if both vectors are equals
  1921. */
  1922. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1923. /**
  1924. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1925. * @param otherVector defines the second operand
  1926. * @param epsilon defines the minimal distance to define values as equals
  1927. * @returns true if both vectors are distant less than epsilon
  1928. */
  1929. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1930. /**
  1931. * Returns true if the current Vector3 coordinates equals the given floats
  1932. * @param x defines the x coordinate of the operand
  1933. * @param y defines the y coordinate of the operand
  1934. * @param z defines the z coordinate of the operand
  1935. * @returns true if both vectors are equals
  1936. */
  1937. equalsToFloats(x: number, y: number, z: number): boolean;
  1938. /**
  1939. * Multiplies the current Vector3 coordinates by the given ones
  1940. * @param otherVector defines the second operand
  1941. * @returns the current updated Vector3
  1942. */
  1943. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1944. /**
  1945. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1946. * @param otherVector defines the second operand
  1947. * @returns the new Vector3
  1948. */
  1949. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1950. /**
  1951. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1952. * @param otherVector defines the second operand
  1953. * @param result defines the Vector3 object where to store the result
  1954. * @returns the current Vector3
  1955. */
  1956. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1959. * @param x defines the x coordinate of the operand
  1960. * @param y defines the y coordinate of the operand
  1961. * @param z defines the z coordinate of the operand
  1962. * @returns the new Vector3
  1963. */
  1964. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1965. /**
  1966. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1967. * @param otherVector defines the second operand
  1968. * @returns the new Vector3
  1969. */
  1970. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1971. /**
  1972. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1973. * @param otherVector defines the second operand
  1974. * @param result defines the Vector3 object where to store the result
  1975. * @returns the current Vector3
  1976. */
  1977. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1978. /**
  1979. * Divides the current Vector3 coordinates by the given ones.
  1980. * @param otherVector defines the second operand
  1981. * @returns the current updated Vector3
  1982. */
  1983. divideInPlace(otherVector: Vector3): Vector3;
  1984. /**
  1985. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1986. * @param other defines the second operand
  1987. * @returns the current updated Vector3
  1988. */
  1989. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1990. /**
  1991. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1992. * @param other defines the second operand
  1993. * @returns the current updated Vector3
  1994. */
  1995. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1996. /**
  1997. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1998. * @param x defines the x coordinate of the operand
  1999. * @param y defines the y coordinate of the operand
  2000. * @param z defines the z coordinate of the operand
  2001. * @returns the current updated Vector3
  2002. */
  2003. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2004. /**
  2005. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2006. * @param x defines the x coordinate of the operand
  2007. * @param y defines the y coordinate of the operand
  2008. * @param z defines the z coordinate of the operand
  2009. * @returns the current updated Vector3
  2010. */
  2011. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2012. /**
  2013. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2014. * Check if is non uniform within a certain amount of decimal places to account for this
  2015. * @param epsilon the amount the values can differ
  2016. * @returns if the the vector is non uniform to a certain number of decimal places
  2017. */
  2018. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2019. /**
  2020. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2021. */
  2022. readonly isNonUniform: boolean;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. floor(): Vector3;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. fract(): Vector3;
  2033. /**
  2034. * Gets the length of the Vector3
  2035. * @returns the length of the Vector3
  2036. */
  2037. length(): number;
  2038. /**
  2039. * Gets the squared length of the Vector3
  2040. * @returns squared length of the Vector3
  2041. */
  2042. lengthSquared(): number;
  2043. /**
  2044. * Normalize the current Vector3.
  2045. * Please note that this is an in place operation.
  2046. * @returns the current updated Vector3
  2047. */
  2048. normalize(): Vector3;
  2049. /**
  2050. * Reorders the x y z properties of the vector in place
  2051. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2052. * @returns the current updated vector
  2053. */
  2054. reorderInPlace(order: string): this;
  2055. /**
  2056. * Rotates the vector around 0,0,0 by a quaternion
  2057. * @param quaternion the rotation quaternion
  2058. * @param result vector to store the result
  2059. * @returns the resulting vector
  2060. */
  2061. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2062. /**
  2063. * Rotates a vector around a given point
  2064. * @param quaternion the rotation quaternion
  2065. * @param point the point to rotate around
  2066. * @param result vector to store the result
  2067. * @returns the resulting vector
  2068. */
  2069. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2070. /**
  2071. * Normalize the current Vector3 with the given input length.
  2072. * Please note that this is an in place operation.
  2073. * @param len the length of the vector
  2074. * @returns the current updated Vector3
  2075. */
  2076. normalizeFromLength(len: number): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to a new vector
  2079. * @returns the new Vector3
  2080. */
  2081. normalizeToNew(): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to the reference
  2084. * @param reference define the Vector3 to update
  2085. * @returns the updated Vector3
  2086. */
  2087. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2088. /**
  2089. * Creates a new Vector3 copied from the current Vector3
  2090. * @returns the new Vector3
  2091. */
  2092. clone(): Vector3;
  2093. /**
  2094. * Copies the given vector coordinates to the current Vector3 ones
  2095. * @param source defines the source Vector3
  2096. * @returns the current updated Vector3
  2097. */
  2098. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2099. /**
  2100. * Copies the given floats to the current Vector3 coordinates
  2101. * @param x defines the x coordinate of the operand
  2102. * @param y defines the y coordinate of the operand
  2103. * @param z defines the z coordinate of the operand
  2104. * @returns the current updated Vector3
  2105. */
  2106. copyFromFloats(x: number, y: number, z: number): Vector3;
  2107. /**
  2108. * Copies the given floats to the current Vector3 coordinates
  2109. * @param x defines the x coordinate of the operand
  2110. * @param y defines the y coordinate of the operand
  2111. * @param z defines the z coordinate of the operand
  2112. * @returns the current updated Vector3
  2113. */
  2114. set(x: number, y: number, z: number): Vector3;
  2115. /**
  2116. * Copies the given float to the current Vector3 coordinates
  2117. * @param v defines the x, y and z coordinates of the operand
  2118. * @returns the current updated Vector3
  2119. */
  2120. setAll(v: number): Vector3;
  2121. /**
  2122. * Get the clip factor between two vectors
  2123. * @param vector0 defines the first operand
  2124. * @param vector1 defines the second operand
  2125. * @param axis defines the axis to use
  2126. * @param size defines the size along the axis
  2127. * @returns the clip factor
  2128. */
  2129. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2130. /**
  2131. * Get angle between two vectors
  2132. * @param vector0 angle between vector0 and vector1
  2133. * @param vector1 angle between vector0 and vector1
  2134. * @param normal direction of the normal
  2135. * @return the angle between vector0 and vector1
  2136. */
  2137. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2138. /**
  2139. * Returns a new Vector3 set from the index "offset" of the given array
  2140. * @param array defines the source array
  2141. * @param offset defines the offset in the source array
  2142. * @returns the new Vector3
  2143. */
  2144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2145. /**
  2146. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2147. * This function is deprecated. Use FromArray instead
  2148. * @param array defines the source array
  2149. * @param offset defines the offset in the source array
  2150. * @returns the new Vector3
  2151. */
  2152. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2153. /**
  2154. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2155. * @param array defines the source array
  2156. * @param offset defines the offset in the source array
  2157. * @param result defines the Vector3 where to store the result
  2158. */
  2159. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2160. /**
  2161. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2162. * This function is deprecated. Use FromArrayToRef instead.
  2163. * @param array defines the source array
  2164. * @param offset defines the offset in the source array
  2165. * @param result defines the Vector3 where to store the result
  2166. */
  2167. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2168. /**
  2169. * Sets the given vector "result" with the given floats.
  2170. * @param x defines the x coordinate of the source
  2171. * @param y defines the y coordinate of the source
  2172. * @param z defines the z coordinate of the source
  2173. * @param result defines the Vector3 where to store the result
  2174. */
  2175. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2178. * @returns a new empty Vector3
  2179. */
  2180. static Zero(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2183. * @returns a new unit Vector3
  2184. */
  2185. static One(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2188. * @returns a new up Vector3
  2189. */
  2190. static Up(): Vector3;
  2191. /**
  2192. * Gets a up Vector3 that must not be updated
  2193. */
  2194. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2195. /**
  2196. * Gets a zero Vector3 that must not be updated
  2197. */
  2198. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2201. * @returns a new down Vector3
  2202. */
  2203. static Down(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Forward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Backward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2216. * @returns a new right Vector3
  2217. */
  2218. static Right(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2221. * @returns a new left Vector3
  2222. */
  2223. static Left(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2226. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2227. * @param vector defines the Vector3 to transform
  2228. * @param transformation defines the transformation matrix
  2229. * @returns the transformed Vector3
  2230. */
  2231. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2232. /**
  2233. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2234. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2235. * @param vector defines the Vector3 to transform
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2242. * This method computes tranformed coordinates only, not transformed direction vectors
  2243. * @param x define the x coordinate of the source vector
  2244. * @param y define the y coordinate of the source vector
  2245. * @param z define the z coordinate of the source vector
  2246. * @param transformation defines the transformation matrix
  2247. * @param result defines the Vector3 where to store the result
  2248. */
  2249. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2250. /**
  2251. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2252. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2253. * @param vector defines the Vector3 to transform
  2254. * @param transformation defines the transformation matrix
  2255. * @returns the new Vector3
  2256. */
  2257. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2258. /**
  2259. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2260. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2261. * @param vector defines the Vector3 to transform
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2268. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2269. * @param x define the x coordinate of the source vector
  2270. * @param y define the y coordinate of the source vector
  2271. * @param z define the z coordinate of the source vector
  2272. * @param transformation defines the transformation matrix
  2273. * @param result defines the Vector3 where to store the result
  2274. */
  2275. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2276. /**
  2277. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2278. * @param value1 defines the first control point
  2279. * @param value2 defines the second control point
  2280. * @param value3 defines the third control point
  2281. * @param value4 defines the fourth control point
  2282. * @param amount defines the amount on the spline to use
  2283. * @returns the new Vector3
  2284. */
  2285. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2286. /**
  2287. * 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"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @returns the new Vector3
  2294. */
  2295. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2296. /**
  2297. * 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"
  2298. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2299. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2300. * @param value defines the current value
  2301. * @param min defines the lower range value
  2302. * @param max defines the upper range value
  2303. * @param result defines the Vector3 where to store the result
  2304. */
  2305. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2306. /**
  2307. * Checks if a given vector is inside a specific range
  2308. * @param v defines the vector to test
  2309. * @param min defines the minimum range
  2310. * @param max defines the maximum range
  2311. */
  2312. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2315. * @param value1 defines the first control point
  2316. * @param tangent1 defines the first tangent vector
  2317. * @param value2 defines the second control point
  2318. * @param tangent2 defines the second tangent vector
  2319. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2320. * @returns the new Vector3
  2321. */
  2322. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2323. /**
  2324. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2325. * @param start defines the start value
  2326. * @param end defines the end value
  2327. * @param amount max defines amount between both (between 0 and 1)
  2328. * @returns the new Vector3
  2329. */
  2330. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2331. /**
  2332. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2333. * @param start defines the start value
  2334. * @param end defines the end value
  2335. * @param amount max defines amount between both (between 0 and 1)
  2336. * @param result defines the Vector3 where to store the result
  2337. */
  2338. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2339. /**
  2340. * Returns the dot product (float) between the vectors "left" and "right"
  2341. * @param left defines the left operand
  2342. * @param right defines the right operand
  2343. * @returns the dot product
  2344. */
  2345. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2346. /**
  2347. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2348. * The cross product is then orthogonal to both "left" and "right"
  2349. * @param left defines the left operand
  2350. * @param right defines the right operand
  2351. * @returns the cross product
  2352. */
  2353. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Sets the given vector "result" with the cross product of "left" and "right"
  2356. * The cross product is then orthogonal to both "left" and "right"
  2357. * @param left defines the left operand
  2358. * @param right defines the right operand
  2359. * @param result defines the Vector3 where to store the result
  2360. */
  2361. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2362. /**
  2363. * Returns a new Vector3 as the normalization of the given vector
  2364. * @param vector defines the Vector3 to normalize
  2365. * @returns the new Vector3
  2366. */
  2367. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2368. /**
  2369. * Sets the given vector "result" with the normalization of the given first vector
  2370. * @param vector defines the Vector3 to normalize
  2371. * @param result defines the Vector3 where to store the result
  2372. */
  2373. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2374. /**
  2375. * Project a Vector3 onto screen space
  2376. * @param vector defines the Vector3 to project
  2377. * @param world defines the world matrix to use
  2378. * @param transform defines the transform (view x projection) matrix to use
  2379. * @param viewport defines the screen viewport to use
  2380. * @returns the new Vector3
  2381. */
  2382. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2383. /** @hidden */
  2384. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2385. /**
  2386. * Unproject from screen space to object space
  2387. * @param source defines the screen space Vector3 to use
  2388. * @param viewportWidth defines the current width of the viewport
  2389. * @param viewportHeight defines the current height of the viewport
  2390. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2391. * @param transform defines the transform (view x projection) matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @returns the new Vector3
  2404. */
  2405. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param source defines the screen space Vector3 to use
  2409. * @param viewportWidth defines the current width of the viewport
  2410. * @param viewportHeight defines the current height of the viewport
  2411. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2412. * @param view defines the view matrix to use
  2413. * @param projection defines the projection matrix to use
  2414. * @param result defines the Vector3 where to store the result
  2415. */
  2416. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2417. /**
  2418. * Unproject from screen space to object space
  2419. * @param sourceX defines the screen space x coordinate to use
  2420. * @param sourceY defines the screen space y coordinate to use
  2421. * @param sourceZ defines the screen space z coordinate to use
  2422. * @param viewportWidth defines the current width of the viewport
  2423. * @param viewportHeight defines the current height of the viewport
  2424. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2425. * @param view defines the view matrix to use
  2426. * @param projection defines the projection matrix to use
  2427. * @param result defines the Vector3 where to store the result
  2428. */
  2429. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2430. /**
  2431. * Gets the minimal coordinate values between two Vector3
  2432. * @param left defines the first operand
  2433. * @param right defines the second operand
  2434. * @returns the new Vector3
  2435. */
  2436. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2437. /**
  2438. * Gets the maximal coordinate values between two Vector3
  2439. * @param left defines the first operand
  2440. * @param right defines the second operand
  2441. * @returns the new Vector3
  2442. */
  2443. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2444. /**
  2445. * Returns the distance between the vectors "value1" and "value2"
  2446. * @param value1 defines the first operand
  2447. * @param value2 defines the second operand
  2448. * @returns the distance
  2449. */
  2450. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2451. /**
  2452. * Returns the squared distance between the vectors "value1" and "value2"
  2453. * @param value1 defines the first operand
  2454. * @param value2 defines the second operand
  2455. * @returns the squared distance
  2456. */
  2457. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2458. /**
  2459. * Returns a new Vector3 located at the center between "value1" and "value2"
  2460. * @param value1 defines the first operand
  2461. * @param value2 defines the second operand
  2462. * @returns the new Vector3
  2463. */
  2464. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2467. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2468. * to something in order to rotate it from its local system to the given target system
  2469. * Note: axis1, axis2 and axis3 are normalized during this operation
  2470. * @param axis1 defines the first axis
  2471. * @param axis2 defines the second axis
  2472. * @param axis3 defines the third axis
  2473. * @returns a new Vector3
  2474. */
  2475. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2476. /**
  2477. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2478. * @param axis1 defines the first axis
  2479. * @param axis2 defines the second axis
  2480. * @param axis3 defines the third axis
  2481. * @param ref defines the Vector3 where to store the result
  2482. */
  2483. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2484. }
  2485. /**
  2486. * Vector4 class created for EulerAngle class conversion to Quaternion
  2487. */
  2488. export class Vector4 {
  2489. /** x value of the vector */
  2490. x: number;
  2491. /** y value of the vector */
  2492. y: number;
  2493. /** z value of the vector */
  2494. z: number;
  2495. /** w value of the vector */
  2496. w: number;
  2497. /**
  2498. * Creates a Vector4 object from the given floats.
  2499. * @param x x value of the vector
  2500. * @param y y value of the vector
  2501. * @param z z value of the vector
  2502. * @param w w value of the vector
  2503. */
  2504. constructor(
  2505. /** x value of the vector */
  2506. x: number,
  2507. /** y value of the vector */
  2508. y: number,
  2509. /** z value of the vector */
  2510. z: number,
  2511. /** w value of the vector */
  2512. w: number);
  2513. /**
  2514. * Returns the string with the Vector4 coordinates.
  2515. * @returns a string containing all the vector values
  2516. */
  2517. toString(): string;
  2518. /**
  2519. * Returns the string "Vector4".
  2520. * @returns "Vector4"
  2521. */
  2522. getClassName(): string;
  2523. /**
  2524. * Returns the Vector4 hash code.
  2525. * @returns a unique hash code
  2526. */
  2527. getHashCode(): number;
  2528. /**
  2529. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2530. * @returns the resulting array
  2531. */
  2532. asArray(): number[];
  2533. /**
  2534. * Populates the given array from the given index with the Vector4 coordinates.
  2535. * @param array array to populate
  2536. * @param index index of the array to start at (default: 0)
  2537. * @returns the Vector4.
  2538. */
  2539. toArray(array: FloatArray, index?: number): Vector4;
  2540. /**
  2541. * Adds the given vector to the current Vector4.
  2542. * @param otherVector the vector to add
  2543. * @returns the updated Vector4.
  2544. */
  2545. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @returns the resulting vector
  2550. */
  2551. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2552. /**
  2553. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2554. * @param otherVector the vector to add
  2555. * @param result the vector to store the result
  2556. * @returns the current Vector4.
  2557. */
  2558. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2559. /**
  2560. * Subtract in place the given vector from the current Vector4.
  2561. * @param otherVector the vector to subtract
  2562. * @returns the updated Vector4.
  2563. */
  2564. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to add
  2568. * @returns the new vector with the result
  2569. */
  2570. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2571. /**
  2572. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2573. * @param otherVector the vector to subtract
  2574. * @param result the vector to store the result
  2575. * @returns the current Vector4.
  2576. */
  2577. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2578. /**
  2579. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2580. */
  2581. /**
  2582. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2583. * @param x value to subtract
  2584. * @param y value to subtract
  2585. * @param z value to subtract
  2586. * @param w value to subtract
  2587. * @returns new vector containing the result
  2588. */
  2589. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2590. /**
  2591. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2592. * @param x value to subtract
  2593. * @param y value to subtract
  2594. * @param z value to subtract
  2595. * @param w value to subtract
  2596. * @param result the vector to store the result in
  2597. * @returns the current Vector4.
  2598. */
  2599. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2602. * @returns a new vector with the negated values
  2603. */
  2604. negate(): Vector4;
  2605. /**
  2606. * Multiplies the current Vector4 coordinates by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns the updated Vector4.
  2609. */
  2610. scaleInPlace(scale: number): Vector4;
  2611. /**
  2612. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @returns a new vector with the result
  2615. */
  2616. scale(scale: number): Vector4;
  2617. /**
  2618. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2619. * @param scale the number to scale with
  2620. * @param result a vector to store the result in
  2621. * @returns the current Vector4.
  2622. */
  2623. scaleToRef(scale: number, result: Vector4): Vector4;
  2624. /**
  2625. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2626. * @param scale defines the scale factor
  2627. * @param result defines the Vector4 object where to store the result
  2628. * @returns the unmodified current Vector4
  2629. */
  2630. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2633. * @param otherVector the vector to compare against
  2634. * @returns true if they are equal
  2635. */
  2636. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2637. /**
  2638. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2639. * @param otherVector vector to compare against
  2640. * @param epsilon (Default: very small number)
  2641. * @returns true if they are equal
  2642. */
  2643. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2644. /**
  2645. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2646. * @param x x value to compare against
  2647. * @param y y value to compare against
  2648. * @param z z value to compare against
  2649. * @param w w value to compare against
  2650. * @returns true if equal
  2651. */
  2652. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2653. /**
  2654. * Multiplies in place the current Vector4 by the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns the updated Vector4.
  2657. */
  2658. multiplyInPlace(otherVector: Vector4): Vector4;
  2659. /**
  2660. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @returns resulting new vector
  2663. */
  2664. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2665. /**
  2666. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2667. * @param otherVector vector to multiple with
  2668. * @param result vector to store the result
  2669. * @returns the current Vector4.
  2670. */
  2671. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2672. /**
  2673. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2674. * @param x x value multiply with
  2675. * @param y y value multiply with
  2676. * @param z z value multiply with
  2677. * @param w w value multiply with
  2678. * @returns resulting new vector
  2679. */
  2680. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2681. /**
  2682. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @returns resulting new vector
  2685. */
  2686. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2687. /**
  2688. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2689. * @param otherVector vector to devide with
  2690. * @param result vector to store the result
  2691. * @returns the current Vector4.
  2692. */
  2693. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2694. /**
  2695. * Divides the current Vector3 coordinates by the given ones.
  2696. * @param otherVector vector to devide with
  2697. * @returns the updated Vector3.
  2698. */
  2699. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2708. * @param other defines the second operand
  2709. * @returns the current updated Vector4
  2710. */
  2711. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2712. /**
  2713. * Gets a new Vector4 from current Vector4 floored values
  2714. * @returns a new Vector4
  2715. */
  2716. floor(): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector3 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. fract(): Vector4;
  2722. /**
  2723. * Returns the Vector4 length (float).
  2724. * @returns the length
  2725. */
  2726. length(): number;
  2727. /**
  2728. * Returns the Vector4 squared length (float).
  2729. * @returns the length squared
  2730. */
  2731. lengthSquared(): number;
  2732. /**
  2733. * Normalizes in place the Vector4.
  2734. * @returns the updated Vector4.
  2735. */
  2736. normalize(): Vector4;
  2737. /**
  2738. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2739. * @returns this converted to a new vector3
  2740. */
  2741. toVector3(): Vector3;
  2742. /**
  2743. * Returns a new Vector4 copied from the current one.
  2744. * @returns the new cloned vector
  2745. */
  2746. clone(): Vector4;
  2747. /**
  2748. * Updates the current Vector4 with the given one coordinates.
  2749. * @param source the source vector to copy from
  2750. * @returns the updated Vector4.
  2751. */
  2752. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2753. /**
  2754. * Updates the current Vector4 coordinates with the given floats.
  2755. * @param x float to copy from
  2756. * @param y float to copy from
  2757. * @param z float to copy from
  2758. * @param w float to copy from
  2759. * @returns the updated Vector4.
  2760. */
  2761. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2762. /**
  2763. * Updates the current Vector4 coordinates with the given floats.
  2764. * @param x float to set from
  2765. * @param y float to set from
  2766. * @param z float to set from
  2767. * @param w float to set from
  2768. * @returns the updated Vector4.
  2769. */
  2770. set(x: number, y: number, z: number, w: number): Vector4;
  2771. /**
  2772. * Copies the given float to the current Vector3 coordinates
  2773. * @param v defines the x, y, z and w coordinates of the operand
  2774. * @returns the current updated Vector3
  2775. */
  2776. setAll(v: number): Vector4;
  2777. /**
  2778. * Returns a new Vector4 set from the starting index of the given array.
  2779. * @param array the array to pull values from
  2780. * @param offset the offset into the array to start at
  2781. * @returns the new vector
  2782. */
  2783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2784. /**
  2785. * Updates the given vector "result" from the starting index of the given array.
  2786. * @param array the array to pull values from
  2787. * @param offset the offset into the array to start at
  2788. * @param result the vector to store the result in
  2789. */
  2790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2791. /**
  2792. * Updates the given vector "result" from the starting index of the given Float32Array.
  2793. * @param array the array to pull values from
  2794. * @param offset the offset into the array to start at
  2795. * @param result the vector to store the result in
  2796. */
  2797. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2798. /**
  2799. * Updates the given vector "result" coordinates from the given floats.
  2800. * @param x float to set from
  2801. * @param y float to set from
  2802. * @param z float to set from
  2803. * @param w float to set from
  2804. * @param result the vector to the floats in
  2805. */
  2806. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2807. /**
  2808. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2809. * @returns the new vector
  2810. */
  2811. static Zero(): Vector4;
  2812. /**
  2813. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2814. * @returns the new vector
  2815. */
  2816. static One(): Vector4;
  2817. /**
  2818. * Returns a new normalized Vector4 from the given one.
  2819. * @param vector the vector to normalize
  2820. * @returns the vector
  2821. */
  2822. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2823. /**
  2824. * Updates the given vector "result" from the normalization of the given one.
  2825. * @param vector the vector to normalize
  2826. * @param result the vector to store the result in
  2827. */
  2828. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2829. /**
  2830. * Returns a vector with the minimum values from the left and right vectors
  2831. * @param left left vector to minimize
  2832. * @param right right vector to minimize
  2833. * @returns a new vector with the minimum of the left and right vector values
  2834. */
  2835. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2836. /**
  2837. * Returns a vector with the maximum values from the left and right vectors
  2838. * @param left left vector to maximize
  2839. * @param right right vector to maximize
  2840. * @returns a new vector with the maximum of the left and right vector values
  2841. */
  2842. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2843. /**
  2844. * Returns the distance (float) between the vectors "value1" and "value2".
  2845. * @param value1 value to calulate the distance between
  2846. * @param value2 value to calulate the distance between
  2847. * @return the distance between the two vectors
  2848. */
  2849. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2850. /**
  2851. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2852. * @param value1 value to calulate the distance between
  2853. * @param value2 value to calulate the distance between
  2854. * @return the distance between the two vectors squared
  2855. */
  2856. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2857. /**
  2858. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2859. * @param value1 value to calulate the center between
  2860. * @param value2 value to calulate the center between
  2861. * @return the center between the two vectors
  2862. */
  2863. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2864. /**
  2865. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2866. * This methods computes transformed normalized direction vectors only.
  2867. * @param vector the vector to transform
  2868. * @param transformation the transformation matrix to apply
  2869. * @returns the new vector
  2870. */
  2871. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2872. /**
  2873. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2874. * This methods computes transformed normalized direction vectors only.
  2875. * @param vector the vector to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the result in
  2878. */
  2879. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2882. * This methods computes transformed normalized direction vectors only.
  2883. * @param x value to transform
  2884. * @param y value to transform
  2885. * @param z value to transform
  2886. * @param w value to transform
  2887. * @param transformation the transformation matrix to apply
  2888. * @param result the vector to store the results in
  2889. */
  2890. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2891. /**
  2892. * Creates a new Vector4 from a Vector3
  2893. * @param source defines the source data
  2894. * @param w defines the 4th component (default is 0)
  2895. * @returns a new Vector4
  2896. */
  2897. static FromVector3(source: Vector3, w?: number): Vector4;
  2898. }
  2899. /**
  2900. * Class used to store quaternion data
  2901. * @see https://en.wikipedia.org/wiki/Quaternion
  2902. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2903. */
  2904. export class Quaternion {
  2905. /** defines the first component (0 by default) */
  2906. x: number;
  2907. /** defines the second component (0 by default) */
  2908. y: number;
  2909. /** defines the third component (0 by default) */
  2910. z: number;
  2911. /** defines the fourth component (1.0 by default) */
  2912. w: number;
  2913. /**
  2914. * Creates a new Quaternion from the given floats
  2915. * @param x defines the first component (0 by default)
  2916. * @param y defines the second component (0 by default)
  2917. * @param z defines the third component (0 by default)
  2918. * @param w defines the fourth component (1.0 by default)
  2919. */
  2920. constructor(
  2921. /** defines the first component (0 by default) */
  2922. x?: number,
  2923. /** defines the second component (0 by default) */
  2924. y?: number,
  2925. /** defines the third component (0 by default) */
  2926. z?: number,
  2927. /** defines the fourth component (1.0 by default) */
  2928. w?: number);
  2929. /**
  2930. * Gets a string representation for the current quaternion
  2931. * @returns a string with the Quaternion coordinates
  2932. */
  2933. toString(): string;
  2934. /**
  2935. * Gets the class name of the quaternion
  2936. * @returns the string "Quaternion"
  2937. */
  2938. getClassName(): string;
  2939. /**
  2940. * Gets a hash code for this quaternion
  2941. * @returns the quaternion hash code
  2942. */
  2943. getHashCode(): number;
  2944. /**
  2945. * Copy the quaternion to an array
  2946. * @returns a new array populated with 4 elements from the quaternion coordinates
  2947. */
  2948. asArray(): number[];
  2949. /**
  2950. * Check if two quaternions are equals
  2951. * @param otherQuaternion defines the second operand
  2952. * @return true if the current quaternion and the given one coordinates are strictly equals
  2953. */
  2954. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2955. /**
  2956. * Clone the current quaternion
  2957. * @returns a new quaternion copied from the current one
  2958. */
  2959. clone(): Quaternion;
  2960. /**
  2961. * Copy a quaternion to the current one
  2962. * @param other defines the other quaternion
  2963. * @returns the updated current quaternion
  2964. */
  2965. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2966. /**
  2967. * Updates the current quaternion with the given float coordinates
  2968. * @param x defines the x coordinate
  2969. * @param y defines the y coordinate
  2970. * @param z defines the z coordinate
  2971. * @param w defines the w coordinate
  2972. * @returns the updated current quaternion
  2973. */
  2974. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2975. /**
  2976. * Updates the current quaternion from the given float coordinates
  2977. * @param x defines the x coordinate
  2978. * @param y defines the y coordinate
  2979. * @param z defines the z coordinate
  2980. * @param w defines the w coordinate
  2981. * @returns the updated current quaternion
  2982. */
  2983. set(x: number, y: number, z: number, w: number): Quaternion;
  2984. /**
  2985. * Adds two quaternions
  2986. * @param other defines the second operand
  2987. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2988. */
  2989. add(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Add a quaternion to the current one
  2992. * @param other defines the quaternion to add
  2993. * @returns the current quaternion
  2994. */
  2995. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2996. /**
  2997. * Subtract two quaternions
  2998. * @param other defines the second operand
  2999. * @returns a new quaternion as the subtraction result of the given one from the current one
  3000. */
  3001. subtract(other: Quaternion): Quaternion;
  3002. /**
  3003. * Multiplies the current quaternion by a scale factor
  3004. * @param value defines the scale factor
  3005. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3006. */
  3007. scale(value: number): Quaternion;
  3008. /**
  3009. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3010. * @param scale defines the scale factor
  3011. * @param result defines the Quaternion object where to store the result
  3012. * @returns the unmodified current quaternion
  3013. */
  3014. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3015. /**
  3016. * Multiplies in place the current quaternion by a scale factor
  3017. * @param value defines the scale factor
  3018. * @returns the current modified quaternion
  3019. */
  3020. scaleInPlace(value: number): Quaternion;
  3021. /**
  3022. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3023. * @param scale defines the scale factor
  3024. * @param result defines the Quaternion object where to store the result
  3025. * @returns the unmodified current quaternion
  3026. */
  3027. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3028. /**
  3029. * Multiplies two quaternions
  3030. * @param q1 defines the second operand
  3031. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3032. */
  3033. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3034. /**
  3035. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3036. * @param q1 defines the second operand
  3037. * @param result defines the target quaternion
  3038. * @returns the current quaternion
  3039. */
  3040. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3041. /**
  3042. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3043. * @param q1 defines the second operand
  3044. * @returns the currentupdated quaternion
  3045. */
  3046. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3047. /**
  3048. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3049. * @param ref defines the target quaternion
  3050. * @returns the current quaternion
  3051. */
  3052. conjugateToRef(ref: Quaternion): Quaternion;
  3053. /**
  3054. * Conjugates in place (1-q) the current quaternion
  3055. * @returns the current updated quaternion
  3056. */
  3057. conjugateInPlace(): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns a new quaternion
  3061. */
  3062. conjugate(): Quaternion;
  3063. /**
  3064. * Gets length of current quaternion
  3065. * @returns the quaternion length (float)
  3066. */
  3067. length(): number;
  3068. /**
  3069. * Normalize in place the current quaternion
  3070. * @returns the current updated quaternion
  3071. */
  3072. normalize(): Quaternion;
  3073. /**
  3074. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3075. * @param order is a reserved parameter and is ignore for now
  3076. * @returns a new Vector3 containing the Euler angles
  3077. */
  3078. toEulerAngles(order?: string): Vector3;
  3079. /**
  3080. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3081. * @param result defines the vector which will be filled with the Euler angles
  3082. * @param order is a reserved parameter and is ignore for now
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toEulerAnglesToRef(result: Vector3): Quaternion;
  3086. /**
  3087. * Updates the given rotation matrix with the current quaternion values
  3088. * @param result defines the target matrix
  3089. * @returns the current unchanged quaternion
  3090. */
  3091. toRotationMatrix(result: Matrix): Quaternion;
  3092. /**
  3093. * Updates the current quaternion from the given rotation matrix values
  3094. * @param matrix defines the source matrix
  3095. * @returns the current updated quaternion
  3096. */
  3097. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Creates a new quaternion from a rotation matrix
  3100. * @param matrix defines the source matrix
  3101. * @returns a new quaternion created from the given rotation matrix values
  3102. */
  3103. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3104. /**
  3105. * Updates the given quaternion with the given rotation matrix values
  3106. * @param matrix defines the source matrix
  3107. * @param result defines the target quaternion
  3108. */
  3109. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3110. /**
  3111. * Returns the dot product (float) between the quaternions "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @returns the dot product
  3115. */
  3116. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3117. /**
  3118. * Checks if the two quaternions are close to each other
  3119. * @param quat0 defines the first quaternion to check
  3120. * @param quat1 defines the second quaternion to check
  3121. * @returns true if the two quaternions are close to each other
  3122. */
  3123. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3124. /**
  3125. * Creates an empty quaternion
  3126. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3127. */
  3128. static Zero(): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @returns a new quaternion as the inverted current quaternion
  3133. */
  3134. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3135. /**
  3136. * Inverse a given quaternion
  3137. * @param q defines the source quaternion
  3138. * @param result the quaternion the result will be stored in
  3139. * @returns the result quaternion
  3140. */
  3141. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3142. /**
  3143. * Creates an identity quaternion
  3144. * @returns the identity quaternion
  3145. */
  3146. static Identity(): Quaternion;
  3147. /**
  3148. * Gets a boolean indicating if the given quaternion is identity
  3149. * @param quaternion defines the quaternion to check
  3150. * @returns true if the quaternion is identity
  3151. */
  3152. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3153. /**
  3154. * Creates a quaternion from a rotation around an axis
  3155. * @param axis defines the axis to use
  3156. * @param angle defines the angle to use
  3157. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3158. */
  3159. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3160. /**
  3161. * Creates a rotation around an axis and stores it into the given quaternion
  3162. * @param axis defines the axis to use
  3163. * @param angle defines the angle to use
  3164. * @param result defines the target quaternion
  3165. * @returns the target quaternion
  3166. */
  3167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3168. /**
  3169. * Creates a new quaternion from data stored into an array
  3170. * @param array defines the data source
  3171. * @param offset defines the offset in the source array where the data starts
  3172. * @returns a new quaternion
  3173. */
  3174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3175. /**
  3176. * Create a quaternion from Euler rotation angles
  3177. * @param x Pitch
  3178. * @param y Yaw
  3179. * @param z Roll
  3180. * @returns the new Quaternion
  3181. */
  3182. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3183. /**
  3184. * Updates a quaternion from Euler rotation angles
  3185. * @param x Pitch
  3186. * @param y Yaw
  3187. * @param z Roll
  3188. * @param result the quaternion to store the result
  3189. * @returns the updated quaternion
  3190. */
  3191. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @returns the new Quaternion
  3196. */
  3197. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3198. /**
  3199. * Updates a quaternion from Euler rotation vector
  3200. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3201. * @param result the quaternion to store the result
  3202. * @returns the updated quaternion
  3203. */
  3204. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3205. /**
  3206. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3207. * @param yaw defines the rotation around Y axis
  3208. * @param pitch defines the rotation around X axis
  3209. * @param roll defines the rotation around Z axis
  3210. * @returns the new quaternion
  3211. */
  3212. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3213. /**
  3214. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3215. * @param yaw defines the rotation around Y axis
  3216. * @param pitch defines the rotation around X axis
  3217. * @param roll defines the rotation around Z axis
  3218. * @param result defines the target quaternion
  3219. */
  3220. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3221. /**
  3222. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3223. * @param alpha defines the rotation around first axis
  3224. * @param beta defines the rotation around second axis
  3225. * @param gamma defines the rotation around third axis
  3226. * @returns the new quaternion
  3227. */
  3228. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3229. /**
  3230. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3231. * @param alpha defines the rotation around first axis
  3232. * @param beta defines the rotation around second axis
  3233. * @param gamma defines the rotation around third axis
  3234. * @param result defines the target quaternion
  3235. */
  3236. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3237. /**
  3238. * 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)
  3239. * @param axis1 defines the first axis
  3240. * @param axis2 defines the second axis
  3241. * @param axis3 defines the third axis
  3242. * @returns the new quaternion
  3243. */
  3244. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3245. /**
  3246. * 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
  3247. * @param axis1 defines the first axis
  3248. * @param axis2 defines the second axis
  3249. * @param axis3 defines the third axis
  3250. * @param ref defines the target quaternion
  3251. */
  3252. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3253. /**
  3254. * Interpolates between two quaternions
  3255. * @param left defines first quaternion
  3256. * @param right defines second quaternion
  3257. * @param amount defines the gradient to use
  3258. * @returns the new interpolated quaternion
  3259. */
  3260. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3261. /**
  3262. * Interpolates between two quaternions and stores it into a target quaternion
  3263. * @param left defines first quaternion
  3264. * @param right defines second quaternion
  3265. * @param amount defines the gradient to use
  3266. * @param result defines the target quaternion
  3267. */
  3268. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3269. /**
  3270. * Interpolate between two quaternions using Hermite interpolation
  3271. * @param value1 defines first quaternion
  3272. * @param tangent1 defines the incoming tangent
  3273. * @param value2 defines second quaternion
  3274. * @param tangent2 defines the outgoing tangent
  3275. * @param amount defines the target quaternion
  3276. * @returns the new interpolated quaternion
  3277. */
  3278. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3279. }
  3280. /**
  3281. * Class used to store matrix data (4x4)
  3282. */
  3283. export class Matrix {
  3284. private static _updateFlagSeed;
  3285. private static _identityReadOnly;
  3286. private _isIdentity;
  3287. private _isIdentityDirty;
  3288. private _isIdentity3x2;
  3289. private _isIdentity3x2Dirty;
  3290. /**
  3291. * Gets the update flag of the matrix which is an unique number for the matrix.
  3292. * It will be incremented every time the matrix data change.
  3293. * You can use it to speed the comparison between two versions of the same matrix.
  3294. */
  3295. updateFlag: number;
  3296. private readonly _m;
  3297. /**
  3298. * Gets the internal data of the matrix
  3299. */
  3300. readonly m: DeepImmutable<Float32Array>;
  3301. /** @hidden */
  3302. _markAsUpdated(): void;
  3303. /** @hidden */
  3304. private _updateIdentityStatus;
  3305. /**
  3306. * Creates an empty matrix (filled with zeros)
  3307. */
  3308. constructor();
  3309. /**
  3310. * Check if the current matrix is identity
  3311. * @returns true is the matrix is the identity matrix
  3312. */
  3313. isIdentity(): boolean;
  3314. /**
  3315. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentityAs3x2(): boolean;
  3319. /**
  3320. * Gets the determinant of the matrix
  3321. * @returns the matrix determinant
  3322. */
  3323. determinant(): number;
  3324. /**
  3325. * Returns the matrix as a Float32Array
  3326. * @returns the matrix underlying array
  3327. */
  3328. toArray(): DeepImmutable<Float32Array>;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array.
  3332. */
  3333. asArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Inverts the current matrix in place
  3336. * @returns the current inverted matrix
  3337. */
  3338. invert(): Matrix;
  3339. /**
  3340. * Sets all the matrix elements to zero
  3341. * @returns the current matrix
  3342. */
  3343. reset(): Matrix;
  3344. /**
  3345. * Adds the current matrix with a second one
  3346. * @param other defines the matrix to add
  3347. * @returns a new matrix as the addition of the current matrix and the given one
  3348. */
  3349. add(other: DeepImmutable<Matrix>): Matrix;
  3350. /**
  3351. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3352. * @param other defines the matrix to add
  3353. * @param result defines the target matrix
  3354. * @returns the current matrix
  3355. */
  3356. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3357. /**
  3358. * Adds in place the given matrix to the current matrix
  3359. * @param other defines the second operand
  3360. * @returns the current updated matrix
  3361. */
  3362. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3363. /**
  3364. * Sets the given matrix to the current inverted Matrix
  3365. * @param other defines the target matrix
  3366. * @returns the unmodified current matrix
  3367. */
  3368. invertToRef(other: Matrix): Matrix;
  3369. /**
  3370. * add a value at the specified position in the current Matrix
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. addAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * mutiply the specified position in the current Matrix by a value
  3378. * @param index the index of the value within the matrix. between 0 and 15.
  3379. * @param value the value to be added
  3380. * @returns the current updated matrix
  3381. */
  3382. multiplyAtIndex(index: number, value: number): Matrix;
  3383. /**
  3384. * Inserts the translation vector (using 3 floats) in the current matrix
  3385. * @param x defines the 1st component of the translation
  3386. * @param y defines the 2nd component of the translation
  3387. * @param z defines the 3rd component of the translation
  3388. * @returns the current updated matrix
  3389. */
  3390. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3391. /**
  3392. * Adds the translation vector (using 3 floats) in the current matrix
  3393. * @param x defines the 1st component of the translation
  3394. * @param y defines the 2nd component of the translation
  3395. * @param z defines the 3rd component of the translation
  3396. * @returns the current updated matrix
  3397. */
  3398. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3399. /**
  3400. * Inserts the translation vector in the current matrix
  3401. * @param vector3 defines the translation to insert
  3402. * @returns the current updated matrix
  3403. */
  3404. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3405. /**
  3406. * Gets the translation value of the current matrix
  3407. * @returns a new Vector3 as the extracted translation from the matrix
  3408. */
  3409. getTranslation(): Vector3;
  3410. /**
  3411. * Fill a Vector3 with the extracted translation from the matrix
  3412. * @param result defines the Vector3 where to store the translation
  3413. * @returns the current matrix
  3414. */
  3415. getTranslationToRef(result: Vector3): Matrix;
  3416. /**
  3417. * Remove rotation and scaling part from the matrix
  3418. * @returns the updated matrix
  3419. */
  3420. removeRotationAndScaling(): Matrix;
  3421. /**
  3422. * Multiply two matrices
  3423. * @param other defines the second operand
  3424. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3425. */
  3426. multiply(other: DeepImmutable<Matrix>): Matrix;
  3427. /**
  3428. * Copy the current matrix from the given one
  3429. * @param other defines the source matrix
  3430. * @returns the current updated matrix
  3431. */
  3432. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3433. /**
  3434. * Populates the given array from the starting index with the current matrix values
  3435. * @param array defines the target array
  3436. * @param offset defines the offset in the target array where to start storing values
  3437. * @returns the current matrix
  3438. */
  3439. copyToArray(array: Float32Array, offset?: number): Matrix;
  3440. /**
  3441. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the matrix where to store the multiplication
  3444. * @returns the current matrix
  3445. */
  3446. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3447. /**
  3448. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3449. * @param other defines the second operand
  3450. * @param result defines the array where to store the multiplication
  3451. * @param offset defines the offset in the target array where to start storing values
  3452. * @returns the current matrix
  3453. */
  3454. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3455. /**
  3456. * Check equality between this matrix and a second one
  3457. * @param value defines the second matrix to compare
  3458. * @returns true is the current matrix and the given one values are strictly equal
  3459. */
  3460. equals(value: DeepImmutable<Matrix>): boolean;
  3461. /**
  3462. * Clone the current matrix
  3463. * @returns a new matrix from the current matrix
  3464. */
  3465. clone(): Matrix;
  3466. /**
  3467. * Returns the name of the current matrix class
  3468. * @returns the string "Matrix"
  3469. */
  3470. getClassName(): string;
  3471. /**
  3472. * Gets the hash code of the current matrix
  3473. * @returns the hash code
  3474. */
  3475. getHashCode(): number;
  3476. /**
  3477. * Decomposes the current Matrix into a translation, rotation and scaling components
  3478. * @param scale defines the scale vector3 given as a reference to update
  3479. * @param rotation defines the rotation quaternion given as a reference to update
  3480. * @param translation defines the translation vector3 given as a reference to update
  3481. * @returns true if operation was successful
  3482. */
  3483. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3484. /**
  3485. * Gets specific row of the matrix
  3486. * @param index defines the number of the row to get
  3487. * @returns the index-th row of the current matrix as a new Vector4
  3488. */
  3489. getRow(index: number): Nullable<Vector4>;
  3490. /**
  3491. * Sets the index-th row of the current matrix to the vector4 values
  3492. * @param index defines the number of the row to set
  3493. * @param row defines the target vector4
  3494. * @returns the updated current matrix
  3495. */
  3496. setRow(index: number, row: Vector4): Matrix;
  3497. /**
  3498. * Compute the transpose of the matrix
  3499. * @returns the new transposed matrix
  3500. */
  3501. transpose(): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix and store it in a given matrix
  3504. * @param result defines the target matrix
  3505. * @returns the current matrix
  3506. */
  3507. transposeToRef(result: Matrix): Matrix;
  3508. /**
  3509. * Sets the index-th row of the current matrix with the given 4 x float values
  3510. * @param index defines the row index
  3511. * @param x defines the x component to set
  3512. * @param y defines the y component to set
  3513. * @param z defines the z component to set
  3514. * @param w defines the w component to set
  3515. * @returns the updated current matrix
  3516. */
  3517. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3518. /**
  3519. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3520. * @param scale defines the scale factor
  3521. * @returns a new matrix
  3522. */
  3523. scale(scale: number): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor to a given result matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Scale the current matrix values by a factor and add the result to a given matrix
  3533. * @param scale defines the scale factor
  3534. * @param result defines the Matrix to store the result
  3535. * @returns the current matrix
  3536. */
  3537. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3538. /**
  3539. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3540. * @param ref matrix to store the result
  3541. */
  3542. toNormalMatrix(ref: Matrix): void;
  3543. /**
  3544. * Gets only rotation part of the current matrix
  3545. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3546. */
  3547. getRotationMatrix(): Matrix;
  3548. /**
  3549. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3550. * @param result defines the target matrix to store data to
  3551. * @returns the current matrix
  3552. */
  3553. getRotationMatrixToRef(result: Matrix): Matrix;
  3554. /**
  3555. * Toggles model matrix from being right handed to left handed in place and vice versa
  3556. */
  3557. toggleModelMatrixHandInPlace(): void;
  3558. /**
  3559. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3560. */
  3561. toggleProjectionMatrixHandInPlace(): void;
  3562. /**
  3563. * Creates a matrix from an array
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @returns a new Matrix set from the starting index of the given array
  3567. */
  3568. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3569. /**
  3570. * Copy the content of an array into a given matrix
  3571. * @param array defines the source array
  3572. * @param offset defines an offset in the source array
  3573. * @param result defines the target matrix
  3574. */
  3575. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3576. /**
  3577. * Stores an array into a matrix after having multiplied each component by a given factor
  3578. * @param array defines the source array
  3579. * @param offset defines the offset in the source array
  3580. * @param scale defines the scaling factor
  3581. * @param result defines the target matrix
  3582. */
  3583. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3584. /**
  3585. * Gets an identity matrix that must not be updated
  3586. */
  3587. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3588. /**
  3589. * Stores a list of values (16) inside a given matrix
  3590. * @param initialM11 defines 1st value of 1st row
  3591. * @param initialM12 defines 2nd value of 1st row
  3592. * @param initialM13 defines 3rd value of 1st row
  3593. * @param initialM14 defines 4th value of 1st row
  3594. * @param initialM21 defines 1st value of 2nd row
  3595. * @param initialM22 defines 2nd value of 2nd row
  3596. * @param initialM23 defines 3rd value of 2nd row
  3597. * @param initialM24 defines 4th value of 2nd row
  3598. * @param initialM31 defines 1st value of 3rd row
  3599. * @param initialM32 defines 2nd value of 3rd row
  3600. * @param initialM33 defines 3rd value of 3rd row
  3601. * @param initialM34 defines 4th value of 3rd row
  3602. * @param initialM41 defines 1st value of 4th row
  3603. * @param initialM42 defines 2nd value of 4th row
  3604. * @param initialM43 defines 3rd value of 4th row
  3605. * @param initialM44 defines 4th value of 4th row
  3606. * @param result defines the target matrix
  3607. */
  3608. 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;
  3609. /**
  3610. * Creates new matrix from a list of values (16)
  3611. * @param initialM11 defines 1st value of 1st row
  3612. * @param initialM12 defines 2nd value of 1st row
  3613. * @param initialM13 defines 3rd value of 1st row
  3614. * @param initialM14 defines 4th value of 1st row
  3615. * @param initialM21 defines 1st value of 2nd row
  3616. * @param initialM22 defines 2nd value of 2nd row
  3617. * @param initialM23 defines 3rd value of 2nd row
  3618. * @param initialM24 defines 4th value of 2nd row
  3619. * @param initialM31 defines 1st value of 3rd row
  3620. * @param initialM32 defines 2nd value of 3rd row
  3621. * @param initialM33 defines 3rd value of 3rd row
  3622. * @param initialM34 defines 4th value of 3rd row
  3623. * @param initialM41 defines 1st value of 4th row
  3624. * @param initialM42 defines 2nd value of 4th row
  3625. * @param initialM43 defines 3rd value of 4th row
  3626. * @param initialM44 defines 4th value of 4th row
  3627. * @returns the new matrix
  3628. */
  3629. 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;
  3630. /**
  3631. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3632. * @param scale defines the scale vector3
  3633. * @param rotation defines the rotation quaternion
  3634. * @param translation defines the translation vector3
  3635. * @returns a new matrix
  3636. */
  3637. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3638. /**
  3639. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3640. * @param scale defines the scale vector3
  3641. * @param rotation defines the rotation quaternion
  3642. * @param translation defines the translation vector3
  3643. * @param result defines the target matrix
  3644. */
  3645. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3646. /**
  3647. * Creates a new identity matrix
  3648. * @returns a new identity matrix
  3649. */
  3650. static Identity(): Matrix;
  3651. /**
  3652. * Creates a new identity matrix and stores the result in a given matrix
  3653. * @param result defines the target matrix
  3654. */
  3655. static IdentityToRef(result: Matrix): void;
  3656. /**
  3657. * Creates a new zero matrix
  3658. * @returns a new zero matrix
  3659. */
  3660. static Zero(): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis
  3663. * @param angle defines the angle (in radians) to use
  3664. * @return the new matrix
  3665. */
  3666. static RotationX(angle: number): Matrix;
  3667. /**
  3668. * Creates a new matrix as the invert of a given matrix
  3669. * @param source defines the source matrix
  3670. * @returns the new matrix
  3671. */
  3672. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationXToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Y axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationY(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationYToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the Z axis
  3693. * @param angle defines the angle (in radians) to use
  3694. * @return the new matrix
  3695. */
  3696. static RotationZ(angle: number): Matrix;
  3697. /**
  3698. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3699. * @param angle defines the angle (in radians) to use
  3700. * @param result defines the target matrix
  3701. */
  3702. static RotationZToRef(angle: number, result: Matrix): void;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @return the new matrix
  3708. */
  3709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3710. /**
  3711. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3712. * @param axis defines the axis to use
  3713. * @param angle defines the angle (in radians) to use
  3714. * @param result defines the target matrix
  3715. */
  3716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3717. /**
  3718. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3719. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3720. * @param from defines the vector to align
  3721. * @param to defines the vector to align to
  3722. * @param result defines the target matrix
  3723. */
  3724. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3725. /**
  3726. * Creates a rotation matrix
  3727. * @param yaw defines the yaw angle in radians (Y axis)
  3728. * @param pitch defines the pitch angle in radians (X axis)
  3729. * @param roll defines the roll angle in radians (X axis)
  3730. * @returns the new rotation matrix
  3731. */
  3732. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3733. /**
  3734. * Creates a rotation matrix and stores it in a given matrix
  3735. * @param yaw defines the yaw angle in radians (Y axis)
  3736. * @param pitch defines the pitch angle in radians (X axis)
  3737. * @param roll defines the roll angle in radians (X axis)
  3738. * @param result defines the target matrix
  3739. */
  3740. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3741. /**
  3742. * Creates a scaling matrix
  3743. * @param x defines the scale factor on X axis
  3744. * @param y defines the scale factor on Y axis
  3745. * @param z defines the scale factor on Z axis
  3746. * @returns the new matrix
  3747. */
  3748. static Scaling(x: number, y: number, z: number): Matrix;
  3749. /**
  3750. * Creates a scaling matrix and stores it in a given matrix
  3751. * @param x defines the scale factor on X axis
  3752. * @param y defines the scale factor on Y axis
  3753. * @param z defines the scale factor on Z axis
  3754. * @param result defines the target matrix
  3755. */
  3756. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3757. /**
  3758. * Creates a translation matrix
  3759. * @param x defines the translation on X axis
  3760. * @param y defines the translation on Y axis
  3761. * @param z defines the translationon Z axis
  3762. * @returns the new matrix
  3763. */
  3764. static Translation(x: number, y: number, z: number): Matrix;
  3765. /**
  3766. * Creates a translation matrix and stores it in a given matrix
  3767. * @param x defines the translation on X axis
  3768. * @param y defines the translation on Y axis
  3769. * @param z defines the translationon Z axis
  3770. * @param result defines the target matrix
  3771. */
  3772. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3773. /**
  3774. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3775. * @param startValue defines the start value
  3776. * @param endValue defines the end value
  3777. * @param gradient defines the gradient factor
  3778. * @returns the new matrix
  3779. */
  3780. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3781. /**
  3782. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3783. * @param startValue defines the start value
  3784. * @param endValue defines the end value
  3785. * @param gradient defines the gradient factor
  3786. * @param result defines the Matrix object where to store data
  3787. */
  3788. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3789. /**
  3790. * Builds a new matrix whose values are computed by:
  3791. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3792. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3793. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3794. * @param startValue defines the first matrix
  3795. * @param endValue defines the second matrix
  3796. * @param gradient defines the gradient between the two matrices
  3797. * @returns the new matrix
  3798. */
  3799. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3800. /**
  3801. * Update a matrix to values which are computed by:
  3802. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3803. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3804. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3805. * @param startValue defines the first matrix
  3806. * @param endValue defines the second matrix
  3807. * @param gradient defines the gradient between the two matrices
  3808. * @param result defines the target matrix
  3809. */
  3810. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3811. /**
  3812. * 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"
  3813. * This function works in left handed mode
  3814. * @param eye defines the final position of the entity
  3815. * @param target defines where the entity should look at
  3816. * @param up defines the up vector for the entity
  3817. * @returns the new matrix
  3818. */
  3819. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3820. /**
  3821. * 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".
  3822. * This function works in left handed mode
  3823. * @param eye defines the final position of the entity
  3824. * @param target defines where the entity should look at
  3825. * @param up defines the up vector for the entity
  3826. * @param result defines the target matrix
  3827. */
  3828. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3829. /**
  3830. * 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"
  3831. * This function works in right handed mode
  3832. * @param eye defines the final position of the entity
  3833. * @param target defines where the entity should look at
  3834. * @param up defines the up vector for the entity
  3835. * @returns the new matrix
  3836. */
  3837. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3838. /**
  3839. * 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".
  3840. * This function works in right handed mode
  3841. * @param eye defines the final position of the entity
  3842. * @param target defines where the entity should look at
  3843. * @param up defines the up vector for the entity
  3844. * @param result defines the target matrix
  3845. */
  3846. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3847. /**
  3848. * Create a left-handed orthographic projection matrix
  3849. * @param width defines the viewport width
  3850. * @param height defines the viewport height
  3851. * @param znear defines the near clip plane
  3852. * @param zfar defines the far clip plane
  3853. * @returns a new matrix as a left-handed orthographic projection matrix
  3854. */
  3855. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3856. /**
  3857. * Store a left-handed orthographic projection to a given matrix
  3858. * @param width defines the viewport width
  3859. * @param height defines the viewport height
  3860. * @param znear defines the near clip plane
  3861. * @param zfar defines the far clip plane
  3862. * @param result defines the target matrix
  3863. */
  3864. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3865. /**
  3866. * Create a left-handed orthographic projection matrix
  3867. * @param left defines the viewport left coordinate
  3868. * @param right defines the viewport right coordinate
  3869. * @param bottom defines the viewport bottom coordinate
  3870. * @param top defines the viewport top coordinate
  3871. * @param znear defines the near clip plane
  3872. * @param zfar defines the far clip plane
  3873. * @returns a new matrix as a left-handed orthographic projection matrix
  3874. */
  3875. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3876. /**
  3877. * Stores a left-handed orthographic projection into a given matrix
  3878. * @param left defines the viewport left coordinate
  3879. * @param right defines the viewport right coordinate
  3880. * @param bottom defines the viewport bottom coordinate
  3881. * @param top defines the viewport top coordinate
  3882. * @param znear defines the near clip plane
  3883. * @param zfar defines the far clip plane
  3884. * @param result defines the target matrix
  3885. */
  3886. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3887. /**
  3888. * Creates a right-handed orthographic projection matrix
  3889. * @param left defines the viewport left coordinate
  3890. * @param right defines the viewport right coordinate
  3891. * @param bottom defines the viewport bottom coordinate
  3892. * @param top defines the viewport top coordinate
  3893. * @param znear defines the near clip plane
  3894. * @param zfar defines the far clip plane
  3895. * @returns a new matrix as a right-handed orthographic projection matrix
  3896. */
  3897. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3898. /**
  3899. * Stores a right-handed orthographic projection into a given matrix
  3900. * @param left defines the viewport left coordinate
  3901. * @param right defines the viewport right coordinate
  3902. * @param bottom defines the viewport bottom coordinate
  3903. * @param top defines the viewport top coordinate
  3904. * @param znear defines the near clip plane
  3905. * @param zfar defines the far clip plane
  3906. * @param result defines the target matrix
  3907. */
  3908. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3909. /**
  3910. * Creates a left-handed perspective projection matrix
  3911. * @param width defines the viewport width
  3912. * @param height defines the viewport height
  3913. * @param znear defines the near clip plane
  3914. * @param zfar defines the far clip plane
  3915. * @returns a new matrix as a left-handed perspective projection matrix
  3916. */
  3917. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3918. /**
  3919. * Creates a left-handed perspective projection matrix
  3920. * @param fov defines the horizontal field of view
  3921. * @param aspect defines the aspect ratio
  3922. * @param znear defines the near clip plane
  3923. * @param zfar defines the far clip plane
  3924. * @returns a new matrix as a left-handed perspective projection matrix
  3925. */
  3926. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3927. /**
  3928. * Stores a left-handed perspective projection into a given matrix
  3929. * @param fov defines the horizontal field of view
  3930. * @param aspect defines the aspect ratio
  3931. * @param znear defines the near clip plane
  3932. * @param zfar defines the far clip plane
  3933. * @param result defines the target matrix
  3934. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3935. */
  3936. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3937. /**
  3938. * Creates a right-handed perspective projection matrix
  3939. * @param fov defines the horizontal field of view
  3940. * @param aspect defines the aspect ratio
  3941. * @param znear defines the near clip plane
  3942. * @param zfar defines the far clip plane
  3943. * @returns a new matrix as a right-handed perspective projection matrix
  3944. */
  3945. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3946. /**
  3947. * Stores a right-handed perspective projection into a given matrix
  3948. * @param fov defines the horizontal field of view
  3949. * @param aspect defines the aspect ratio
  3950. * @param znear defines the near clip plane
  3951. * @param zfar defines the far clip plane
  3952. * @param result defines the target matrix
  3953. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3954. */
  3955. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3956. /**
  3957. * Stores a perspective projection for WebVR info a given matrix
  3958. * @param fov defines the field of view
  3959. * @param znear defines the near clip plane
  3960. * @param zfar defines the far clip plane
  3961. * @param result defines the target matrix
  3962. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3963. */
  3964. static PerspectiveFovWebVRToRef(fov: {
  3965. upDegrees: number;
  3966. downDegrees: number;
  3967. leftDegrees: number;
  3968. rightDegrees: number;
  3969. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3970. /**
  3971. * Computes a complete transformation matrix
  3972. * @param viewport defines the viewport to use
  3973. * @param world defines the world matrix
  3974. * @param view defines the view matrix
  3975. * @param projection defines the projection matrix
  3976. * @param zmin defines the near clip plane
  3977. * @param zmax defines the far clip plane
  3978. * @returns the transformation matrix
  3979. */
  3980. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3981. /**
  3982. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3983. * @param matrix defines the matrix to use
  3984. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3985. */
  3986. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3987. /**
  3988. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3989. * @param matrix defines the matrix to use
  3990. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3991. */
  3992. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3993. /**
  3994. * Compute the transpose of a given matrix
  3995. * @param matrix defines the matrix to transpose
  3996. * @returns the new matrix
  3997. */
  3998. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3999. /**
  4000. * Compute the transpose of a matrix and store it in a target matrix
  4001. * @param matrix defines the matrix to transpose
  4002. * @param result defines the target matrix
  4003. */
  4004. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4005. /**
  4006. * Computes a reflection matrix from a plane
  4007. * @param plane defines the reflection plane
  4008. * @returns a new matrix
  4009. */
  4010. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4011. /**
  4012. * Computes a reflection matrix from a plane
  4013. * @param plane defines the reflection plane
  4014. * @param result defines the target matrix
  4015. */
  4016. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4017. /**
  4018. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4019. * @param xaxis defines the value of the 1st axis
  4020. * @param yaxis defines the value of the 2nd axis
  4021. * @param zaxis defines the value of the 3rd axis
  4022. * @param result defines the target matrix
  4023. */
  4024. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4025. /**
  4026. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4027. * @param quat defines the quaternion to use
  4028. * @param result defines the target matrix
  4029. */
  4030. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4031. }
  4032. /**
  4033. * @hidden
  4034. */
  4035. export class TmpVectors {
  4036. static Vector2: Vector2[];
  4037. static Vector3: Vector3[];
  4038. static Vector4: Vector4[];
  4039. static Quaternion: Quaternion[];
  4040. static Matrix: Matrix[];
  4041. }
  4042. }
  4043. declare module BABYLON {
  4044. /** Defines the cross module used constants to avoid circular dependncies */
  4045. export class Constants {
  4046. /** Defines that alpha blending is disabled */
  4047. static readonly ALPHA_DISABLE: number;
  4048. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4049. static readonly ALPHA_ADD: number;
  4050. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4051. static readonly ALPHA_COMBINE: number;
  4052. /** Defines that alpha blending to DEST - SRC * DEST */
  4053. static readonly ALPHA_SUBTRACT: number;
  4054. /** Defines that alpha blending to SRC * DEST */
  4055. static readonly ALPHA_MULTIPLY: number;
  4056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4057. static readonly ALPHA_MAXIMIZED: number;
  4058. /** Defines that alpha blending to SRC + DEST */
  4059. static readonly ALPHA_ONEONE: number;
  4060. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4061. static readonly ALPHA_PREMULTIPLIED: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4064. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4067. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4068. static readonly ALPHA_INTERPOLATE: number;
  4069. /**
  4070. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4071. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4072. */
  4073. static readonly ALPHA_SCREENMODE: number;
  4074. /** Defines that the ressource is not delayed*/
  4075. static readonly DELAYLOADSTATE_NONE: number;
  4076. /** Defines that the ressource was successfully delay loaded */
  4077. static readonly DELAYLOADSTATE_LOADED: number;
  4078. /** Defines that the ressource is currently delay loading */
  4079. static readonly DELAYLOADSTATE_LOADING: number;
  4080. /** Defines that the ressource is delayed and has not started loading */
  4081. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4083. static readonly NEVER: number;
  4084. /** 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 */
  4085. static readonly ALWAYS: number;
  4086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4087. static readonly LESS: number;
  4088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4089. static readonly EQUAL: number;
  4090. /** 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 */
  4091. static readonly LEQUAL: number;
  4092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4093. static readonly GREATER: number;
  4094. /** 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 */
  4095. static readonly GEQUAL: number;
  4096. /** 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 */
  4097. static readonly NOTEQUAL: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be kept */
  4099. static readonly KEEP: number;
  4100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4101. static readonly REPLACE: number;
  4102. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4103. static readonly INCR: number;
  4104. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4105. static readonly DECR: number;
  4106. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4107. static readonly INVERT: number;
  4108. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4109. static readonly INCR_WRAP: number;
  4110. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4111. static readonly DECR_WRAP: number;
  4112. /** Texture is not repeating outside of 0..1 UVs */
  4113. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4114. /** Texture is repeating outside of 0..1 UVs */
  4115. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4116. /** Texture is repeating and mirrored */
  4117. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4118. /** ALPHA */
  4119. static readonly TEXTUREFORMAT_ALPHA: number;
  4120. /** LUMINANCE */
  4121. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4122. /** LUMINANCE_ALPHA */
  4123. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4124. /** RGB */
  4125. static readonly TEXTUREFORMAT_RGB: number;
  4126. /** RGBA */
  4127. static readonly TEXTUREFORMAT_RGBA: number;
  4128. /** RED */
  4129. static readonly TEXTUREFORMAT_RED: number;
  4130. /** RED (2nd reference) */
  4131. static readonly TEXTUREFORMAT_R: number;
  4132. /** RG */
  4133. static readonly TEXTUREFORMAT_RG: number;
  4134. /** RED_INTEGER */
  4135. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4136. /** RED_INTEGER (2nd reference) */
  4137. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4138. /** RG_INTEGER */
  4139. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4140. /** RGB_INTEGER */
  4141. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4142. /** RGBA_INTEGER */
  4143. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4144. /** UNSIGNED_BYTE */
  4145. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4146. /** UNSIGNED_BYTE (2nd reference) */
  4147. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4148. /** FLOAT */
  4149. static readonly TEXTURETYPE_FLOAT: number;
  4150. /** HALF_FLOAT */
  4151. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4152. /** BYTE */
  4153. static readonly TEXTURETYPE_BYTE: number;
  4154. /** SHORT */
  4155. static readonly TEXTURETYPE_SHORT: number;
  4156. /** UNSIGNED_SHORT */
  4157. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4158. /** INT */
  4159. static readonly TEXTURETYPE_INT: number;
  4160. /** UNSIGNED_INT */
  4161. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4162. /** UNSIGNED_SHORT_4_4_4_4 */
  4163. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4164. /** UNSIGNED_SHORT_5_5_5_1 */
  4165. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4166. /** UNSIGNED_SHORT_5_6_5 */
  4167. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4168. /** UNSIGNED_INT_2_10_10_10_REV */
  4169. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4170. /** UNSIGNED_INT_24_8 */
  4171. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4172. /** UNSIGNED_INT_10F_11F_11F_REV */
  4173. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4174. /** UNSIGNED_INT_5_9_9_9_REV */
  4175. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4176. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4177. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4178. /** nearest is mag = nearest and min = nearest and mip = linear */
  4179. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4180. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4181. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4182. /** Trilinear is mag = linear and min = linear and mip = linear */
  4183. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4184. /** nearest is mag = nearest and min = nearest and mip = linear */
  4185. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4187. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4188. /** Trilinear is mag = linear and min = linear and mip = linear */
  4189. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4190. /** mag = nearest and min = nearest and mip = nearest */
  4191. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4192. /** mag = nearest and min = linear and mip = nearest */
  4193. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4194. /** mag = nearest and min = linear and mip = linear */
  4195. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4196. /** mag = nearest and min = linear and mip = none */
  4197. static readonly TEXTURE_NEAREST_LINEAR: number;
  4198. /** mag = nearest and min = nearest and mip = none */
  4199. static readonly TEXTURE_NEAREST_NEAREST: number;
  4200. /** mag = linear and min = nearest and mip = nearest */
  4201. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4202. /** mag = linear and min = nearest and mip = linear */
  4203. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4204. /** mag = linear and min = linear and mip = none */
  4205. static readonly TEXTURE_LINEAR_LINEAR: number;
  4206. /** mag = linear and min = nearest and mip = none */
  4207. static readonly TEXTURE_LINEAR_NEAREST: number;
  4208. /** Explicit coordinates mode */
  4209. static readonly TEXTURE_EXPLICIT_MODE: number;
  4210. /** Spherical coordinates mode */
  4211. static readonly TEXTURE_SPHERICAL_MODE: number;
  4212. /** Planar coordinates mode */
  4213. static readonly TEXTURE_PLANAR_MODE: number;
  4214. /** Cubic coordinates mode */
  4215. static readonly TEXTURE_CUBIC_MODE: number;
  4216. /** Projection coordinates mode */
  4217. static readonly TEXTURE_PROJECTION_MODE: number;
  4218. /** Skybox coordinates mode */
  4219. static readonly TEXTURE_SKYBOX_MODE: number;
  4220. /** Inverse Cubic coordinates mode */
  4221. static readonly TEXTURE_INVCUBIC_MODE: number;
  4222. /** Equirectangular coordinates mode */
  4223. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4224. /** Equirectangular Fixed coordinates mode */
  4225. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4226. /** Equirectangular Fixed Mirrored coordinates mode */
  4227. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4228. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4229. static readonly SCALEMODE_FLOOR: number;
  4230. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4231. static readonly SCALEMODE_NEAREST: number;
  4232. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4233. static readonly SCALEMODE_CEILING: number;
  4234. /**
  4235. * The dirty texture flag value
  4236. */
  4237. static readonly MATERIAL_TextureDirtyFlag: number;
  4238. /**
  4239. * The dirty light flag value
  4240. */
  4241. static readonly MATERIAL_LightDirtyFlag: number;
  4242. /**
  4243. * The dirty fresnel flag value
  4244. */
  4245. static readonly MATERIAL_FresnelDirtyFlag: number;
  4246. /**
  4247. * The dirty attribute flag value
  4248. */
  4249. static readonly MATERIAL_AttributesDirtyFlag: number;
  4250. /**
  4251. * The dirty misc flag value
  4252. */
  4253. static readonly MATERIAL_MiscDirtyFlag: number;
  4254. /**
  4255. * The all dirty flag value
  4256. */
  4257. static readonly MATERIAL_AllDirtyFlag: number;
  4258. /**
  4259. * Returns the triangle fill mode
  4260. */
  4261. static readonly MATERIAL_TriangleFillMode: number;
  4262. /**
  4263. * Returns the wireframe mode
  4264. */
  4265. static readonly MATERIAL_WireFrameFillMode: number;
  4266. /**
  4267. * Returns the point fill mode
  4268. */
  4269. static readonly MATERIAL_PointFillMode: number;
  4270. /**
  4271. * Returns the point list draw mode
  4272. */
  4273. static readonly MATERIAL_PointListDrawMode: number;
  4274. /**
  4275. * Returns the line list draw mode
  4276. */
  4277. static readonly MATERIAL_LineListDrawMode: number;
  4278. /**
  4279. * Returns the line loop draw mode
  4280. */
  4281. static readonly MATERIAL_LineLoopDrawMode: number;
  4282. /**
  4283. * Returns the line strip draw mode
  4284. */
  4285. static readonly MATERIAL_LineStripDrawMode: number;
  4286. /**
  4287. * Returns the triangle strip draw mode
  4288. */
  4289. static readonly MATERIAL_TriangleStripDrawMode: number;
  4290. /**
  4291. * Returns the triangle fan draw mode
  4292. */
  4293. static readonly MATERIAL_TriangleFanDrawMode: number;
  4294. /**
  4295. * Stores the clock-wise side orientation
  4296. */
  4297. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4298. /**
  4299. * Stores the counter clock-wise side orientation
  4300. */
  4301. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4302. /**
  4303. * Nothing
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_NothingTrigger: number;
  4307. /**
  4308. * On pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnPickTrigger: number;
  4312. /**
  4313. * On left pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnLeftPickTrigger: number;
  4317. /**
  4318. * On right pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnRightPickTrigger: number;
  4322. /**
  4323. * On center pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnCenterPickTrigger: number;
  4327. /**
  4328. * On pick down
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnPickDownTrigger: number;
  4332. /**
  4333. * On double pick
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnDoublePickTrigger: number;
  4337. /**
  4338. * On pick up
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnPickUpTrigger: number;
  4342. /**
  4343. * On pick out.
  4344. * This trigger will only be raised if you also declared a OnPickDown
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnPickOutTrigger: number;
  4348. /**
  4349. * On long press
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnLongPressTrigger: number;
  4353. /**
  4354. * On pointer over
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOverTrigger: number;
  4358. /**
  4359. * On pointer out
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOutTrigger: number;
  4363. /**
  4364. * On every frame
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnEveryFrameTrigger: number;
  4368. /**
  4369. * On intersection enter
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4373. /**
  4374. * On intersection exit
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionExitTrigger: number;
  4378. /**
  4379. * On key down
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyDownTrigger: number;
  4383. /**
  4384. * On key up
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyUpTrigger: number;
  4388. /**
  4389. * Billboard mode will only apply to Y axis
  4390. */
  4391. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4392. /**
  4393. * Billboard mode will apply to all axes
  4394. */
  4395. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4396. /**
  4397. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4398. */
  4399. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4400. /**
  4401. * Gets or sets base Assets URL
  4402. */
  4403. static PARTICLES_BaseAssetsUrl: string;
  4404. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4405. * Test order :
  4406. * Is the bounding sphere outside the frustum ?
  4407. * If not, are the bounding box vertices outside the frustum ?
  4408. * It not, then the cullable object is in the frustum.
  4409. */
  4410. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4411. /** Culling strategy : Bounding Sphere Only.
  4412. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4413. * It's also less accurate than the standard because some not visible objects can still be selected.
  4414. * Test : is the bounding sphere outside the frustum ?
  4415. * If not, then the cullable object is in the frustum.
  4416. */
  4417. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4418. /** Culling strategy : Optimistic Inclusion.
  4419. * This in an inclusion test first, then the standard exclusion test.
  4420. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4421. * 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.
  4422. * Anyway, it's as accurate as the standard strategy.
  4423. * Test :
  4424. * Is the cullable object bounding sphere center in the frustum ?
  4425. * If not, apply the default culling strategy.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4428. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4429. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4430. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4431. * 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.
  4432. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4433. * Test :
  4434. * Is the cullable object bounding sphere center in the frustum ?
  4435. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4436. */
  4437. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4438. /**
  4439. * No logging while loading
  4440. */
  4441. static readonly SCENELOADER_NO_LOGGING: number;
  4442. /**
  4443. * Minimal logging while loading
  4444. */
  4445. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4446. /**
  4447. * Summary logging while loading
  4448. */
  4449. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4450. /**
  4451. * Detailled logging while loading
  4452. */
  4453. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4454. }
  4455. }
  4456. declare module BABYLON {
  4457. /**
  4458. * Class used to store and describe the pipeline context associated with an effect
  4459. */
  4460. export interface IPipelineContext {
  4461. /**
  4462. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4463. */
  4464. isAsync: boolean;
  4465. /**
  4466. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4467. */
  4468. isReady: boolean;
  4469. /** @hidden */
  4470. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface IShaderProcessor {
  4476. attributeProcessor?: (attribute: string) => string;
  4477. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4478. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4479. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4480. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4481. lineProcessor?: (line: string, isFragment: boolean) => string;
  4482. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4483. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4484. }
  4485. }
  4486. declare module BABYLON {
  4487. /** @hidden */
  4488. export interface ProcessingOptions {
  4489. defines: string[];
  4490. indexParameters: any;
  4491. isFragment: boolean;
  4492. shouldUseHighPrecisionShader: boolean;
  4493. supportsUniformBuffers: boolean;
  4494. shadersRepository: string;
  4495. includesShadersStore: {
  4496. [key: string]: string;
  4497. };
  4498. processor?: IShaderProcessor;
  4499. version: string;
  4500. platformName: string;
  4501. lookForClosingBracketForUniformBuffer?: boolean;
  4502. }
  4503. }
  4504. declare module BABYLON {
  4505. /**
  4506. * Helper to manipulate strings
  4507. */
  4508. export class StringTools {
  4509. /**
  4510. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4511. * @param str Source string
  4512. * @param suffix Suffix to search for in the source string
  4513. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4514. */
  4515. static EndsWith(str: string, suffix: string): boolean;
  4516. /**
  4517. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4518. * @param str Source string
  4519. * @param suffix Suffix to search for in the source string
  4520. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4521. */
  4522. static StartsWith(str: string, suffix: string): boolean;
  4523. }
  4524. }
  4525. declare module BABYLON {
  4526. /** @hidden */
  4527. export class ShaderCodeNode {
  4528. line: string;
  4529. children: ShaderCodeNode[];
  4530. additionalDefineKey?: string;
  4531. additionalDefineValue?: string;
  4532. isValid(preprocessors: {
  4533. [key: string]: string;
  4534. }): boolean;
  4535. process(preprocessors: {
  4536. [key: string]: string;
  4537. }, options: ProcessingOptions): string;
  4538. }
  4539. }
  4540. declare module BABYLON {
  4541. /** @hidden */
  4542. export class ShaderCodeCursor {
  4543. private _lines;
  4544. lineIndex: number;
  4545. readonly currentLine: string;
  4546. readonly canRead: boolean;
  4547. lines: string[];
  4548. }
  4549. }
  4550. declare module BABYLON {
  4551. /** @hidden */
  4552. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4553. process(preprocessors: {
  4554. [key: string]: string;
  4555. }, options: ProcessingOptions): string;
  4556. }
  4557. }
  4558. declare module BABYLON {
  4559. /** @hidden */
  4560. export class ShaderDefineExpression {
  4561. isTrue(preprocessors: {
  4562. [key: string]: string;
  4563. }): boolean;
  4564. }
  4565. }
  4566. declare module BABYLON {
  4567. /** @hidden */
  4568. export class ShaderCodeTestNode extends ShaderCodeNode {
  4569. testExpression: ShaderDefineExpression;
  4570. isValid(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module BABYLON {
  4576. /** @hidden */
  4577. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4578. define: string;
  4579. not: boolean;
  4580. constructor(define: string, not?: boolean);
  4581. isTrue(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. /** @hidden */
  4588. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4589. leftOperand: ShaderDefineExpression;
  4590. rightOperand: ShaderDefineExpression;
  4591. isTrue(preprocessors: {
  4592. [key: string]: string;
  4593. }): boolean;
  4594. }
  4595. }
  4596. declare module BABYLON {
  4597. /** @hidden */
  4598. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4599. leftOperand: ShaderDefineExpression;
  4600. rightOperand: ShaderDefineExpression;
  4601. isTrue(preprocessors: {
  4602. [key: string]: string;
  4603. }): boolean;
  4604. }
  4605. }
  4606. declare module BABYLON {
  4607. /** @hidden */
  4608. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4609. define: string;
  4610. operand: string;
  4611. testValue: string;
  4612. constructor(define: string, operand: string, testValue: string);
  4613. isTrue(preprocessors: {
  4614. [key: string]: string;
  4615. }): boolean;
  4616. }
  4617. }
  4618. declare module BABYLON {
  4619. /**
  4620. * @ignore
  4621. * Application error to support additional information when loading a file
  4622. */
  4623. export class LoadFileError extends Error {
  4624. /** defines the optional web request */
  4625. request?: WebRequest | undefined;
  4626. private static _setPrototypeOf;
  4627. /**
  4628. * Creates a new LoadFileError
  4629. * @param message defines the message of the error
  4630. * @param request defines the optional web request
  4631. */
  4632. constructor(message: string,
  4633. /** defines the optional web request */
  4634. request?: WebRequest | undefined);
  4635. }
  4636. }
  4637. declare module BABYLON {
  4638. /**
  4639. * Class used to enable access to offline support
  4640. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4641. */
  4642. export interface IOfflineProvider {
  4643. /**
  4644. * Gets a boolean indicating if scene must be saved in the database
  4645. */
  4646. enableSceneOffline: boolean;
  4647. /**
  4648. * Gets a boolean indicating if textures must be saved in the database
  4649. */
  4650. enableTexturesOffline: boolean;
  4651. /**
  4652. * Open the offline support and make it available
  4653. * @param successCallback defines the callback to call on success
  4654. * @param errorCallback defines the callback to call on error
  4655. */
  4656. open(successCallback: () => void, errorCallback: () => void): void;
  4657. /**
  4658. * Loads an image from the offline support
  4659. * @param url defines the url to load from
  4660. * @param image defines the target DOM image
  4661. */
  4662. loadImage(url: string, image: HTMLImageElement): void;
  4663. /**
  4664. * Loads a file from offline support
  4665. * @param url defines the URL to load from
  4666. * @param sceneLoaded defines a callback to call on success
  4667. * @param progressCallBack defines a callback to call when progress changed
  4668. * @param errorCallback defines a callback to call on error
  4669. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4670. */
  4671. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4672. }
  4673. }
  4674. declare module BABYLON {
  4675. /**
  4676. * Class used to help managing file picking and drag'n'drop
  4677. * File Storage
  4678. */
  4679. export class FilesInputStore {
  4680. /**
  4681. * List of files ready to be loaded
  4682. */
  4683. static FilesToLoad: {
  4684. [key: string]: File;
  4685. };
  4686. }
  4687. }
  4688. declare module BABYLON {
  4689. /**
  4690. * Class used to define a retry strategy when error happens while loading assets
  4691. */
  4692. export class RetryStrategy {
  4693. /**
  4694. * Function used to defines an exponential back off strategy
  4695. * @param maxRetries defines the maximum number of retries (3 by default)
  4696. * @param baseInterval defines the interval between retries
  4697. * @returns the strategy function to use
  4698. */
  4699. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4700. }
  4701. }
  4702. declare module BABYLON {
  4703. /**
  4704. * @hidden
  4705. */
  4706. export class FileTools {
  4707. /**
  4708. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4709. */
  4710. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4711. /**
  4712. * Gets or sets the base URL to use to load assets
  4713. */
  4714. static BaseUrl: string;
  4715. /**
  4716. * Default behaviour for cors in the application.
  4717. * It can be a string if the expected behavior is identical in the entire app.
  4718. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4719. */
  4720. static CorsBehavior: string | ((url: string | string[]) => string);
  4721. /**
  4722. * Gets or sets a function used to pre-process url before using them to load assets
  4723. */
  4724. static PreprocessUrl: (url: string) => string;
  4725. /**
  4726. * Removes unwanted characters from an url
  4727. * @param url defines the url to clean
  4728. * @returns the cleaned url
  4729. */
  4730. private static _CleanUrl;
  4731. /**
  4732. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4733. * @param url define the url we are trying
  4734. * @param element define the dom element where to configure the cors policy
  4735. */
  4736. static SetCorsBehavior(url: string | string[], element: {
  4737. crossOrigin: string | null;
  4738. }): void;
  4739. /**
  4740. * Loads an image as an HTMLImageElement.
  4741. * @param input url string, ArrayBuffer, or Blob to load
  4742. * @param onLoad callback called when the image successfully loads
  4743. * @param onError callback called when the image fails to load
  4744. * @param offlineProvider offline provider for caching
  4745. * @returns the HTMLImageElement of the loaded image
  4746. */
  4747. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4748. /**
  4749. * Loads a file
  4750. * @param fileToLoad defines the file to load
  4751. * @param callback defines the callback to call when data is loaded
  4752. * @param progressCallBack defines the callback to call during loading process
  4753. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4754. * @returns a file request object
  4755. */
  4756. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4757. /**
  4758. * Loads a file
  4759. * @param url url string, ArrayBuffer, or Blob to load
  4760. * @param onSuccess callback called when the file successfully loads
  4761. * @param onProgress callback called while file is loading (if the server supports this mode)
  4762. * @param offlineProvider defines the offline provider for caching
  4763. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4764. * @param onError callback called when the file fails to load
  4765. * @returns a file request object
  4766. */
  4767. 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;
  4768. /**
  4769. * Checks if the loaded document was accessed via `file:`-Protocol.
  4770. * @returns boolean
  4771. */
  4772. static IsFileURL(): boolean;
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /** @hidden */
  4777. export class ShaderProcessor {
  4778. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4779. private static _ProcessPrecision;
  4780. private static _ExtractOperation;
  4781. private static _BuildSubExpression;
  4782. private static _BuildExpression;
  4783. private static _MoveCursorWithinIf;
  4784. private static _MoveCursor;
  4785. private static _EvaluatePreProcessors;
  4786. private static _PreparePreProcessors;
  4787. private static _ProcessShaderConversion;
  4788. private static _ProcessIncludes;
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Class used to hold a RBG color
  4794. */
  4795. export class Color3 {
  4796. /**
  4797. * Defines the red component (between 0 and 1, default is 0)
  4798. */
  4799. r: number;
  4800. /**
  4801. * Defines the green component (between 0 and 1, default is 0)
  4802. */
  4803. g: number;
  4804. /**
  4805. * Defines the blue component (between 0 and 1, default is 0)
  4806. */
  4807. b: number;
  4808. /**
  4809. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4810. * @param r defines the red component (between 0 and 1, default is 0)
  4811. * @param g defines the green component (between 0 and 1, default is 0)
  4812. * @param b defines the blue component (between 0 and 1, default is 0)
  4813. */
  4814. constructor(
  4815. /**
  4816. * Defines the red component (between 0 and 1, default is 0)
  4817. */
  4818. r?: number,
  4819. /**
  4820. * Defines the green component (between 0 and 1, default is 0)
  4821. */
  4822. g?: number,
  4823. /**
  4824. * Defines the blue component (between 0 and 1, default is 0)
  4825. */
  4826. b?: number);
  4827. /**
  4828. * Creates a string with the Color3 current values
  4829. * @returns the string representation of the Color3 object
  4830. */
  4831. toString(): string;
  4832. /**
  4833. * Returns the string "Color3"
  4834. * @returns "Color3"
  4835. */
  4836. getClassName(): string;
  4837. /**
  4838. * Compute the Color3 hash code
  4839. * @returns an unique number that can be used to hash Color3 objects
  4840. */
  4841. getHashCode(): number;
  4842. /**
  4843. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4844. * @param array defines the array where to store the r,g,b components
  4845. * @param index defines an optional index in the target array to define where to start storing values
  4846. * @returns the current Color3 object
  4847. */
  4848. toArray(array: FloatArray, index?: number): Color3;
  4849. /**
  4850. * Returns a new Color4 object from the current Color3 and the given alpha
  4851. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4852. * @returns a new Color4 object
  4853. */
  4854. toColor4(alpha?: number): Color4;
  4855. /**
  4856. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4857. * @returns the new array
  4858. */
  4859. asArray(): number[];
  4860. /**
  4861. * Returns the luminance value
  4862. * @returns a float value
  4863. */
  4864. toLuminance(): number;
  4865. /**
  4866. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4867. * @param otherColor defines the second operand
  4868. * @returns the new Color3 object
  4869. */
  4870. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4871. /**
  4872. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4873. * @param otherColor defines the second operand
  4874. * @param result defines the Color3 object where to store the result
  4875. * @returns the current Color3
  4876. */
  4877. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4878. /**
  4879. * Determines equality between Color3 objects
  4880. * @param otherColor defines the second operand
  4881. * @returns true if the rgb values are equal to the given ones
  4882. */
  4883. equals(otherColor: DeepImmutable<Color3>): boolean;
  4884. /**
  4885. * Determines equality between the current Color3 object and a set of r,b,g values
  4886. * @param r defines the red component to check
  4887. * @param g defines the green component to check
  4888. * @param b defines the blue component to check
  4889. * @returns true if the rgb values are equal to the given ones
  4890. */
  4891. equalsFloats(r: number, g: number, b: number): boolean;
  4892. /**
  4893. * Multiplies in place each rgb value by scale
  4894. * @param scale defines the scaling factor
  4895. * @returns the updated Color3
  4896. */
  4897. scale(scale: number): Color3;
  4898. /**
  4899. * Multiplies the rgb values by scale and stores the result into "result"
  4900. * @param scale defines the scaling factor
  4901. * @param result defines the Color3 object where to store the result
  4902. * @returns the unmodified current Color3
  4903. */
  4904. scaleToRef(scale: number, result: Color3): Color3;
  4905. /**
  4906. * Scale the current Color3 values by a factor and add the result to a given Color3
  4907. * @param scale defines the scale factor
  4908. * @param result defines color to store the result into
  4909. * @returns the unmodified current Color3
  4910. */
  4911. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4912. /**
  4913. * Clamps the rgb values by the min and max values and stores the result into "result"
  4914. * @param min defines minimum clamping value (default is 0)
  4915. * @param max defines maximum clamping value (default is 1)
  4916. * @param result defines color to store the result into
  4917. * @returns the original Color3
  4918. */
  4919. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4920. /**
  4921. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. add(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4935. * @param otherColor defines the second operand
  4936. * @returns the new Color3
  4937. */
  4938. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4939. /**
  4940. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4941. * @param otherColor defines the second operand
  4942. * @param result defines Color3 object to store the result into
  4943. * @returns the unmodified current Color3
  4944. */
  4945. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4946. /**
  4947. * Copy the current object
  4948. * @returns a new Color3 copied the current one
  4949. */
  4950. clone(): Color3;
  4951. /**
  4952. * Copies the rgb values from the source in the current Color3
  4953. * @param source defines the source Color3 object
  4954. * @returns the updated Color3 object
  4955. */
  4956. copyFrom(source: DeepImmutable<Color3>): Color3;
  4957. /**
  4958. * Updates the Color3 rgb values from the given floats
  4959. * @param r defines the red component to read from
  4960. * @param g defines the green component to read from
  4961. * @param b defines the blue component to read from
  4962. * @returns the current Color3 object
  4963. */
  4964. copyFromFloats(r: number, g: number, b: number): Color3;
  4965. /**
  4966. * Updates the Color3 rgb values from the given floats
  4967. * @param r defines the red component to read from
  4968. * @param g defines the green component to read from
  4969. * @param b defines the blue component to read from
  4970. * @returns the current Color3 object
  4971. */
  4972. set(r: number, g: number, b: number): Color3;
  4973. /**
  4974. * Compute the Color3 hexadecimal code as a string
  4975. * @returns a string containing the hexadecimal representation of the Color3 object
  4976. */
  4977. toHexString(): string;
  4978. /**
  4979. * Computes a new Color3 converted from the current one to linear space
  4980. * @returns a new Color3 object
  4981. */
  4982. toLinearSpace(): Color3;
  4983. /**
  4984. * Converts current color in rgb space to HSV values
  4985. * @returns a new color3 representing the HSV values
  4986. */
  4987. toHSV(): Color3;
  4988. /**
  4989. * Converts current color in rgb space to HSV values
  4990. * @param result defines the Color3 where to store the HSV values
  4991. */
  4992. toHSVToRef(result: Color3): void;
  4993. /**
  4994. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4995. * @param convertedColor defines the Color3 object where to store the linear space version
  4996. * @returns the unmodified Color3
  4997. */
  4998. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4999. /**
  5000. * Computes a new Color3 converted from the current one to gamma space
  5001. * @returns a new Color3 object
  5002. */
  5003. toGammaSpace(): Color3;
  5004. /**
  5005. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5006. * @param convertedColor defines the Color3 object where to store the gamma space version
  5007. * @returns the unmodified Color3
  5008. */
  5009. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5010. private static _BlackReadOnly;
  5011. /**
  5012. * Convert Hue, saturation and value to a Color3 (RGB)
  5013. * @param hue defines the hue
  5014. * @param saturation defines the saturation
  5015. * @param value defines the value
  5016. * @param result defines the Color3 where to store the RGB values
  5017. */
  5018. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5019. /**
  5020. * Creates a new Color3 from the string containing valid hexadecimal values
  5021. * @param hex defines a string containing valid hexadecimal values
  5022. * @returns a new Color3 object
  5023. */
  5024. static FromHexString(hex: string): Color3;
  5025. /**
  5026. * Creates a new Color3 from the starting index of the given array
  5027. * @param array defines the source array
  5028. * @param offset defines an offset in the source array
  5029. * @returns a new Color3 object
  5030. */
  5031. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5032. /**
  5033. * Creates a new Color3 from integer values (< 256)
  5034. * @param r defines the red component to read from (value between 0 and 255)
  5035. * @param g defines the green component to read from (value between 0 and 255)
  5036. * @param b defines the blue component to read from (value between 0 and 255)
  5037. * @returns a new Color3 object
  5038. */
  5039. static FromInts(r: number, g: number, b: number): Color3;
  5040. /**
  5041. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5042. * @param start defines the start Color3 value
  5043. * @param end defines the end Color3 value
  5044. * @param amount defines the gradient value between start and end
  5045. * @returns a new Color3 object
  5046. */
  5047. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5048. /**
  5049. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5050. * @param left defines the start value
  5051. * @param right defines the end value
  5052. * @param amount defines the gradient factor
  5053. * @param result defines the Color3 object where to store the result
  5054. */
  5055. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5056. /**
  5057. * Returns a Color3 value containing a red color
  5058. * @returns a new Color3 object
  5059. */
  5060. static Red(): Color3;
  5061. /**
  5062. * Returns a Color3 value containing a green color
  5063. * @returns a new Color3 object
  5064. */
  5065. static Green(): Color3;
  5066. /**
  5067. * Returns a Color3 value containing a blue color
  5068. * @returns a new Color3 object
  5069. */
  5070. static Blue(): Color3;
  5071. /**
  5072. * Returns a Color3 value containing a black color
  5073. * @returns a new Color3 object
  5074. */
  5075. static Black(): Color3;
  5076. /**
  5077. * Gets a Color3 value containing a black color that must not be updated
  5078. */
  5079. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5080. /**
  5081. * Returns a Color3 value containing a white color
  5082. * @returns a new Color3 object
  5083. */
  5084. static White(): Color3;
  5085. /**
  5086. * Returns a Color3 value containing a purple color
  5087. * @returns a new Color3 object
  5088. */
  5089. static Purple(): Color3;
  5090. /**
  5091. * Returns a Color3 value containing a magenta color
  5092. * @returns a new Color3 object
  5093. */
  5094. static Magenta(): Color3;
  5095. /**
  5096. * Returns a Color3 value containing a yellow color
  5097. * @returns a new Color3 object
  5098. */
  5099. static Yellow(): Color3;
  5100. /**
  5101. * Returns a Color3 value containing a gray color
  5102. * @returns a new Color3 object
  5103. */
  5104. static Gray(): Color3;
  5105. /**
  5106. * Returns a Color3 value containing a teal color
  5107. * @returns a new Color3 object
  5108. */
  5109. static Teal(): Color3;
  5110. /**
  5111. * Returns a Color3 value containing a random color
  5112. * @returns a new Color3 object
  5113. */
  5114. static Random(): Color3;
  5115. }
  5116. /**
  5117. * Class used to hold a RBGA color
  5118. */
  5119. export class Color4 {
  5120. /**
  5121. * Defines the red component (between 0 and 1, default is 0)
  5122. */
  5123. r: number;
  5124. /**
  5125. * Defines the green component (between 0 and 1, default is 0)
  5126. */
  5127. g: number;
  5128. /**
  5129. * Defines the blue component (between 0 and 1, default is 0)
  5130. */
  5131. b: number;
  5132. /**
  5133. * Defines the alpha component (between 0 and 1, default is 1)
  5134. */
  5135. a: number;
  5136. /**
  5137. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5138. * @param r defines the red component (between 0 and 1, default is 0)
  5139. * @param g defines the green component (between 0 and 1, default is 0)
  5140. * @param b defines the blue component (between 0 and 1, default is 0)
  5141. * @param a defines the alpha component (between 0 and 1, default is 1)
  5142. */
  5143. constructor(
  5144. /**
  5145. * Defines the red component (between 0 and 1, default is 0)
  5146. */
  5147. r?: number,
  5148. /**
  5149. * Defines the green component (between 0 and 1, default is 0)
  5150. */
  5151. g?: number,
  5152. /**
  5153. * Defines the blue component (between 0 and 1, default is 0)
  5154. */
  5155. b?: number,
  5156. /**
  5157. * Defines the alpha component (between 0 and 1, default is 1)
  5158. */
  5159. a?: number);
  5160. /**
  5161. * Adds in place the given Color4 values to the current Color4 object
  5162. * @param right defines the second operand
  5163. * @returns the current updated Color4 object
  5164. */
  5165. addInPlace(right: DeepImmutable<Color4>): Color4;
  5166. /**
  5167. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Stores from the starting index in the given array the Color4 successive values
  5173. * @param array defines the array where to store the r,g,b components
  5174. * @param index defines an optional index in the target array to define where to start storing values
  5175. * @returns the current Color4 object
  5176. */
  5177. toArray(array: number[], index?: number): Color4;
  5178. /**
  5179. * Determines equality between Color4 objects
  5180. * @param otherColor defines the second operand
  5181. * @returns true if the rgba values are equal to the given ones
  5182. */
  5183. equals(otherColor: DeepImmutable<Color4>): boolean;
  5184. /**
  5185. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5186. * @param right defines the second operand
  5187. * @returns a new Color4 object
  5188. */
  5189. add(right: DeepImmutable<Color4>): Color4;
  5190. /**
  5191. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5192. * @param right defines the second operand
  5193. * @returns a new Color4 object
  5194. */
  5195. subtract(right: DeepImmutable<Color4>): Color4;
  5196. /**
  5197. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5198. * @param right defines the second operand
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current Color4 object
  5201. */
  5202. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5203. /**
  5204. * Creates a new Color4 with the current Color4 values multiplied by scale
  5205. * @param scale defines the scaling factor to apply
  5206. * @returns a new Color4 object
  5207. */
  5208. scale(scale: number): Color4;
  5209. /**
  5210. * Multiplies the current Color4 values by scale and stores the result in "result"
  5211. * @param scale defines the scaling factor to apply
  5212. * @param result defines the Color4 object where to store the result
  5213. * @returns the current unmodified Color4
  5214. */
  5215. scaleToRef(scale: number, result: Color4): Color4;
  5216. /**
  5217. * Scale the current Color4 values by a factor and add the result to a given Color4
  5218. * @param scale defines the scale factor
  5219. * @param result defines the Color4 object where to store the result
  5220. * @returns the unmodified current Color4
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into.
  5228. * @returns the cuurent Color4
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5231. /**
  5232. * Multipy an Color4 value by another and return a new Color4 object
  5233. * @param color defines the Color4 value to multiply by
  5234. * @returns a new Color4 object
  5235. */
  5236. multiply(color: Color4): Color4;
  5237. /**
  5238. * Multipy a Color4 value by another and push the result in a reference value
  5239. * @param color defines the Color4 value to multiply by
  5240. * @param result defines the Color4 to fill the result in
  5241. * @returns the result Color4
  5242. */
  5243. multiplyToRef(color: Color4, result: Color4): Color4;
  5244. /**
  5245. * Creates a string with the Color4 current values
  5246. * @returns the string representation of the Color4 object
  5247. */
  5248. toString(): string;
  5249. /**
  5250. * Returns the string "Color4"
  5251. * @returns "Color4"
  5252. */
  5253. getClassName(): string;
  5254. /**
  5255. * Compute the Color4 hash code
  5256. * @returns an unique number that can be used to hash Color4 objects
  5257. */
  5258. getHashCode(): number;
  5259. /**
  5260. * Creates a new Color4 copied from the current one
  5261. * @returns a new Color4 object
  5262. */
  5263. clone(): Color4;
  5264. /**
  5265. * Copies the given Color4 values into the current one
  5266. * @param source defines the source Color4 object
  5267. * @returns the current updated Color4 object
  5268. */
  5269. copyFrom(source: Color4): Color4;
  5270. /**
  5271. * Copies the given float values into the current one
  5272. * @param r defines the red component to read from
  5273. * @param g defines the green component to read from
  5274. * @param b defines the blue component to read from
  5275. * @param a defines the alpha component to read from
  5276. * @returns the current updated Color4 object
  5277. */
  5278. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5279. /**
  5280. * Copies the given float values into the current one
  5281. * @param r defines the red component to read from
  5282. * @param g defines the green component to read from
  5283. * @param b defines the blue component to read from
  5284. * @param a defines the alpha component to read from
  5285. * @returns the current updated Color4 object
  5286. */
  5287. set(r: number, g: number, b: number, a: number): Color4;
  5288. /**
  5289. * Compute the Color4 hexadecimal code as a string
  5290. * @returns a string containing the hexadecimal representation of the Color4 object
  5291. */
  5292. toHexString(): string;
  5293. /**
  5294. * Computes a new Color4 converted from the current one to linear space
  5295. * @returns a new Color4 object
  5296. */
  5297. toLinearSpace(): Color4;
  5298. /**
  5299. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5300. * @param convertedColor defines the Color4 object where to store the linear space version
  5301. * @returns the unmodified Color4
  5302. */
  5303. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5304. /**
  5305. * Computes a new Color4 converted from the current one to gamma space
  5306. * @returns a new Color4 object
  5307. */
  5308. toGammaSpace(): Color4;
  5309. /**
  5310. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5311. * @param convertedColor defines the Color4 object where to store the gamma space version
  5312. * @returns the unmodified Color4
  5313. */
  5314. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5315. /**
  5316. * Creates a new Color4 from the string containing valid hexadecimal values
  5317. * @param hex defines a string containing valid hexadecimal values
  5318. * @returns a new Color4 object
  5319. */
  5320. static FromHexString(hex: string): Color4;
  5321. /**
  5322. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5323. * @param left defines the start value
  5324. * @param right defines the end value
  5325. * @param amount defines the gradient factor
  5326. * @returns a new Color4 object
  5327. */
  5328. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5329. /**
  5330. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5331. * @param left defines the start value
  5332. * @param right defines the end value
  5333. * @param amount defines the gradient factor
  5334. * @param result defines the Color4 object where to store data
  5335. */
  5336. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5337. /**
  5338. * Creates a new Color4 from a Color3 and an alpha value
  5339. * @param color3 defines the source Color3 to read from
  5340. * @param alpha defines the alpha component (1.0 by default)
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5344. /**
  5345. * Creates a new Color4 from the starting index element of the given array
  5346. * @param array defines the source array to read from
  5347. * @param offset defines the offset in the source array
  5348. * @returns a new Color4 object
  5349. */
  5350. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5351. /**
  5352. * Creates a new Color3 from integer values (< 256)
  5353. * @param r defines the red component to read from (value between 0 and 255)
  5354. * @param g defines the green component to read from (value between 0 and 255)
  5355. * @param b defines the blue component to read from (value between 0 and 255)
  5356. * @param a defines the alpha component to read from (value between 0 and 255)
  5357. * @returns a new Color3 object
  5358. */
  5359. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5360. /**
  5361. * Check the content of a given array and convert it to an array containing RGBA data
  5362. * If the original array was already containing count * 4 values then it is returned directly
  5363. * @param colors defines the array to check
  5364. * @param count defines the number of RGBA data to expect
  5365. * @returns an array containing count * 4 values (RGBA)
  5366. */
  5367. static CheckColors4(colors: number[], count: number): number[];
  5368. }
  5369. /**
  5370. * @hidden
  5371. */
  5372. export class TmpColors {
  5373. static Color3: Color3[];
  5374. static Color4: Color4[];
  5375. }
  5376. }
  5377. declare module BABYLON {
  5378. /**
  5379. * Class representing spherical harmonics coefficients to the 3rd degree
  5380. */
  5381. export class SphericalHarmonics {
  5382. /**
  5383. * Defines whether or not the harmonics have been prescaled for rendering.
  5384. */
  5385. preScaled: boolean;
  5386. /**
  5387. * The l0,0 coefficients of the spherical harmonics
  5388. */
  5389. l00: Vector3;
  5390. /**
  5391. * The l1,-1 coefficients of the spherical harmonics
  5392. */
  5393. l1_1: Vector3;
  5394. /**
  5395. * The l1,0 coefficients of the spherical harmonics
  5396. */
  5397. l10: Vector3;
  5398. /**
  5399. * The l1,1 coefficients of the spherical harmonics
  5400. */
  5401. l11: Vector3;
  5402. /**
  5403. * The l2,-2 coefficients of the spherical harmonics
  5404. */
  5405. l2_2: Vector3;
  5406. /**
  5407. * The l2,-1 coefficients of the spherical harmonics
  5408. */
  5409. l2_1: Vector3;
  5410. /**
  5411. * The l2,0 coefficients of the spherical harmonics
  5412. */
  5413. l20: Vector3;
  5414. /**
  5415. * The l2,1 coefficients of the spherical harmonics
  5416. */
  5417. l21: Vector3;
  5418. /**
  5419. * The l2,2 coefficients of the spherical harmonics
  5420. */
  5421. l22: Vector3;
  5422. /**
  5423. * Adds a light to the spherical harmonics
  5424. * @param direction the direction of the light
  5425. * @param color the color of the light
  5426. * @param deltaSolidAngle the delta solid angle of the light
  5427. */
  5428. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5429. /**
  5430. * Scales the spherical harmonics by the given amount
  5431. * @param scale the amount to scale
  5432. */
  5433. scaleInPlace(scale: number): void;
  5434. /**
  5435. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5436. *
  5437. * ```
  5438. * E_lm = A_l * L_lm
  5439. * ```
  5440. *
  5441. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5442. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5443. * the scaling factors are given in equation 9.
  5444. */
  5445. convertIncidentRadianceToIrradiance(): void;
  5446. /**
  5447. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5448. *
  5449. * ```
  5450. * L = (1/pi) * E * rho
  5451. * ```
  5452. *
  5453. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5454. */
  5455. convertIrradianceToLambertianRadiance(): void;
  5456. /**
  5457. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5458. * required operations at run time.
  5459. *
  5460. * This is simply done by scaling back the SH with Ylm constants parameter.
  5461. * The trigonometric part being applied by the shader at run time.
  5462. */
  5463. preScaleForRendering(): void;
  5464. /**
  5465. * Constructs a spherical harmonics from an array.
  5466. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5467. * @returns the spherical harmonics
  5468. */
  5469. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5470. /**
  5471. * Gets the spherical harmonics from polynomial
  5472. * @param polynomial the spherical polynomial
  5473. * @returns the spherical harmonics
  5474. */
  5475. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5476. }
  5477. /**
  5478. * Class representing spherical polynomial coefficients to the 3rd degree
  5479. */
  5480. export class SphericalPolynomial {
  5481. private _harmonics;
  5482. /**
  5483. * The spherical harmonics used to create the polynomials.
  5484. */
  5485. readonly preScaledHarmonics: SphericalHarmonics;
  5486. /**
  5487. * The x coefficients of the spherical polynomial
  5488. */
  5489. x: Vector3;
  5490. /**
  5491. * The y coefficients of the spherical polynomial
  5492. */
  5493. y: Vector3;
  5494. /**
  5495. * The z coefficients of the spherical polynomial
  5496. */
  5497. z: Vector3;
  5498. /**
  5499. * The xx coefficients of the spherical polynomial
  5500. */
  5501. xx: Vector3;
  5502. /**
  5503. * The yy coefficients of the spherical polynomial
  5504. */
  5505. yy: Vector3;
  5506. /**
  5507. * The zz coefficients of the spherical polynomial
  5508. */
  5509. zz: Vector3;
  5510. /**
  5511. * The xy coefficients of the spherical polynomial
  5512. */
  5513. xy: Vector3;
  5514. /**
  5515. * The yz coefficients of the spherical polynomial
  5516. */
  5517. yz: Vector3;
  5518. /**
  5519. * The zx coefficients of the spherical polynomial
  5520. */
  5521. zx: Vector3;
  5522. /**
  5523. * Adds an ambient color to the spherical polynomial
  5524. * @param color the color to add
  5525. */
  5526. addAmbient(color: Color3): void;
  5527. /**
  5528. * Scales the spherical polynomial by the given amount
  5529. * @param scale the amount to scale
  5530. */
  5531. scaleInPlace(scale: number): void;
  5532. /**
  5533. * Gets the spherical polynomial from harmonics
  5534. * @param harmonics the spherical harmonics
  5535. * @returns the spherical polynomial
  5536. */
  5537. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5538. /**
  5539. * Constructs a spherical polynomial from an array.
  5540. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5541. * @returns the spherical polynomial
  5542. */
  5543. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5544. }
  5545. }
  5546. declare module BABYLON {
  5547. /**
  5548. * Define options used to create a render target texture
  5549. */
  5550. export class RenderTargetCreationOptions {
  5551. /**
  5552. * Specifies is mipmaps must be generated
  5553. */
  5554. generateMipMaps?: boolean;
  5555. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5556. generateDepthBuffer?: boolean;
  5557. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5558. generateStencilBuffer?: boolean;
  5559. /** Defines texture type (int by default) */
  5560. type?: number;
  5561. /** Defines sampling mode (trilinear by default) */
  5562. samplingMode?: number;
  5563. /** Defines format (RGBA by default) */
  5564. format?: number;
  5565. }
  5566. }
  5567. declare module BABYLON {
  5568. /**
  5569. * @hidden
  5570. **/
  5571. export class _AlphaState {
  5572. private _isAlphaBlendDirty;
  5573. private _isBlendFunctionParametersDirty;
  5574. private _isBlendEquationParametersDirty;
  5575. private _isBlendConstantsDirty;
  5576. private _alphaBlend;
  5577. private _blendFunctionParameters;
  5578. private _blendEquationParameters;
  5579. private _blendConstants;
  5580. /**
  5581. * Initializes the state.
  5582. */
  5583. constructor();
  5584. readonly isDirty: boolean;
  5585. alphaBlend: boolean;
  5586. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5587. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5588. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5589. reset(): void;
  5590. apply(gl: WebGLRenderingContext): void;
  5591. }
  5592. }
  5593. declare module BABYLON {
  5594. /**
  5595. * @hidden
  5596. **/
  5597. export class _DepthCullingState {
  5598. private _isDepthTestDirty;
  5599. private _isDepthMaskDirty;
  5600. private _isDepthFuncDirty;
  5601. private _isCullFaceDirty;
  5602. private _isCullDirty;
  5603. private _isZOffsetDirty;
  5604. private _isFrontFaceDirty;
  5605. private _depthTest;
  5606. private _depthMask;
  5607. private _depthFunc;
  5608. private _cull;
  5609. private _cullFace;
  5610. private _zOffset;
  5611. private _frontFace;
  5612. /**
  5613. * Initializes the state.
  5614. */
  5615. constructor();
  5616. readonly isDirty: boolean;
  5617. zOffset: number;
  5618. cullFace: Nullable<number>;
  5619. cull: Nullable<boolean>;
  5620. depthFunc: Nullable<number>;
  5621. depthMask: boolean;
  5622. depthTest: boolean;
  5623. frontFace: Nullable<number>;
  5624. reset(): void;
  5625. apply(gl: WebGLRenderingContext): void;
  5626. }
  5627. }
  5628. declare module BABYLON {
  5629. /**
  5630. * @hidden
  5631. **/
  5632. export class _StencilState {
  5633. /** 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 */
  5634. static readonly ALWAYS: number;
  5635. /** Passed to stencilOperation to specify that stencil value must be kept */
  5636. static readonly KEEP: number;
  5637. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5638. static readonly REPLACE: number;
  5639. private _isStencilTestDirty;
  5640. private _isStencilMaskDirty;
  5641. private _isStencilFuncDirty;
  5642. private _isStencilOpDirty;
  5643. private _stencilTest;
  5644. private _stencilMask;
  5645. private _stencilFunc;
  5646. private _stencilFuncRef;
  5647. private _stencilFuncMask;
  5648. private _stencilOpStencilFail;
  5649. private _stencilOpDepthFail;
  5650. private _stencilOpStencilDepthPass;
  5651. readonly isDirty: boolean;
  5652. stencilFunc: number;
  5653. stencilFuncRef: number;
  5654. stencilFuncMask: number;
  5655. stencilOpStencilFail: number;
  5656. stencilOpDepthFail: number;
  5657. stencilOpStencilDepthPass: number;
  5658. stencilMask: number;
  5659. stencilTest: boolean;
  5660. constructor();
  5661. reset(): void;
  5662. apply(gl: WebGLRenderingContext): void;
  5663. }
  5664. }
  5665. declare module BABYLON {
  5666. /**
  5667. * @hidden
  5668. **/
  5669. export class _TimeToken {
  5670. _startTimeQuery: Nullable<WebGLQuery>;
  5671. _endTimeQuery: Nullable<WebGLQuery>;
  5672. _timeElapsedQuery: Nullable<WebGLQuery>;
  5673. _timeElapsedQueryEnded: boolean;
  5674. }
  5675. }
  5676. declare module BABYLON {
  5677. /**
  5678. * Class used to evalaute queries containing `and` and `or` operators
  5679. */
  5680. export class AndOrNotEvaluator {
  5681. /**
  5682. * Evaluate a query
  5683. * @param query defines the query to evaluate
  5684. * @param evaluateCallback defines the callback used to filter result
  5685. * @returns true if the query matches
  5686. */
  5687. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5688. private static _HandleParenthesisContent;
  5689. private static _SimplifyNegation;
  5690. }
  5691. }
  5692. declare module BABYLON {
  5693. /**
  5694. * Class used to store custom tags
  5695. */
  5696. export class Tags {
  5697. /**
  5698. * Adds support for tags on the given object
  5699. * @param obj defines the object to use
  5700. */
  5701. static EnableFor(obj: any): void;
  5702. /**
  5703. * Removes tags support
  5704. * @param obj defines the object to use
  5705. */
  5706. static DisableFor(obj: any): void;
  5707. /**
  5708. * Gets a boolean indicating if the given object has tags
  5709. * @param obj defines the object to use
  5710. * @returns a boolean
  5711. */
  5712. static HasTags(obj: any): boolean;
  5713. /**
  5714. * Gets the tags available on a given object
  5715. * @param obj defines the object to use
  5716. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5717. * @returns the tags
  5718. */
  5719. static GetTags(obj: any, asString?: boolean): any;
  5720. /**
  5721. * Adds tags to an object
  5722. * @param obj defines the object to use
  5723. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5724. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5725. */
  5726. static AddTagsTo(obj: any, tagsString: string): void;
  5727. /**
  5728. * @hidden
  5729. */
  5730. static _AddTagTo(obj: any, tag: string): void;
  5731. /**
  5732. * Removes specific tags from a specific object
  5733. * @param obj defines the object to use
  5734. * @param tagsString defines the tags to remove
  5735. */
  5736. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5737. /**
  5738. * @hidden
  5739. */
  5740. static _RemoveTagFrom(obj: any, tag: string): void;
  5741. /**
  5742. * Defines if tags hosted on an object match a given query
  5743. * @param obj defines the object to use
  5744. * @param tagsQuery defines the tag query
  5745. * @returns a boolean
  5746. */
  5747. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5748. }
  5749. }
  5750. declare module BABYLON {
  5751. /**
  5752. * Defines potential orientation for back face culling
  5753. */
  5754. export enum Orientation {
  5755. /**
  5756. * Clockwise
  5757. */
  5758. CW = 0,
  5759. /** Counter clockwise */
  5760. CCW = 1
  5761. }
  5762. /** Class used to represent a Bezier curve */
  5763. export class BezierCurve {
  5764. /**
  5765. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5766. * @param t defines the time
  5767. * @param x1 defines the left coordinate on X axis
  5768. * @param y1 defines the left coordinate on Y axis
  5769. * @param x2 defines the right coordinate on X axis
  5770. * @param y2 defines the right coordinate on Y axis
  5771. * @returns the interpolated value
  5772. */
  5773. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5774. }
  5775. /**
  5776. * Defines angle representation
  5777. */
  5778. export class Angle {
  5779. private _radians;
  5780. /**
  5781. * Creates an Angle object of "radians" radians (float).
  5782. * @param radians the angle in radians
  5783. */
  5784. constructor(radians: number);
  5785. /**
  5786. * Get value in degrees
  5787. * @returns the Angle value in degrees (float)
  5788. */
  5789. degrees(): number;
  5790. /**
  5791. * Get value in radians
  5792. * @returns the Angle value in radians (float)
  5793. */
  5794. radians(): number;
  5795. /**
  5796. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5797. * @param a defines first vector
  5798. * @param b defines second vector
  5799. * @returns a new Angle
  5800. */
  5801. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5802. /**
  5803. * Gets a new Angle object from the given float in radians
  5804. * @param radians defines the angle value in radians
  5805. * @returns a new Angle
  5806. */
  5807. static FromRadians(radians: number): Angle;
  5808. /**
  5809. * Gets a new Angle object from the given float in degrees
  5810. * @param degrees defines the angle value in degrees
  5811. * @returns a new Angle
  5812. */
  5813. static FromDegrees(degrees: number): Angle;
  5814. }
  5815. /**
  5816. * This represents an arc in a 2d space.
  5817. */
  5818. export class Arc2 {
  5819. /** Defines the start point of the arc */
  5820. startPoint: Vector2;
  5821. /** Defines the mid point of the arc */
  5822. midPoint: Vector2;
  5823. /** Defines the end point of the arc */
  5824. endPoint: Vector2;
  5825. /**
  5826. * Defines the center point of the arc.
  5827. */
  5828. centerPoint: Vector2;
  5829. /**
  5830. * Defines the radius of the arc.
  5831. */
  5832. radius: number;
  5833. /**
  5834. * Defines the angle of the arc (from mid point to end point).
  5835. */
  5836. angle: Angle;
  5837. /**
  5838. * Defines the start angle of the arc (from start point to middle point).
  5839. */
  5840. startAngle: Angle;
  5841. /**
  5842. * Defines the orientation of the arc (clock wise/counter clock wise).
  5843. */
  5844. orientation: Orientation;
  5845. /**
  5846. * Creates an Arc object from the three given points : start, middle and end.
  5847. * @param startPoint Defines the start point of the arc
  5848. * @param midPoint Defines the midlle point of the arc
  5849. * @param endPoint Defines the end point of the arc
  5850. */
  5851. constructor(
  5852. /** Defines the start point of the arc */
  5853. startPoint: Vector2,
  5854. /** Defines the mid point of the arc */
  5855. midPoint: Vector2,
  5856. /** Defines the end point of the arc */
  5857. endPoint: Vector2);
  5858. }
  5859. /**
  5860. * Represents a 2D path made up of multiple 2D points
  5861. */
  5862. export class Path2 {
  5863. private _points;
  5864. private _length;
  5865. /**
  5866. * If the path start and end point are the same
  5867. */
  5868. closed: boolean;
  5869. /**
  5870. * Creates a Path2 object from the starting 2D coordinates x and y.
  5871. * @param x the starting points x value
  5872. * @param y the starting points y value
  5873. */
  5874. constructor(x: number, y: number);
  5875. /**
  5876. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5877. * @param x the added points x value
  5878. * @param y the added points y value
  5879. * @returns the updated Path2.
  5880. */
  5881. addLineTo(x: number, y: number): Path2;
  5882. /**
  5883. * 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.
  5884. * @param midX middle point x value
  5885. * @param midY middle point y value
  5886. * @param endX end point x value
  5887. * @param endY end point y value
  5888. * @param numberOfSegments (default: 36)
  5889. * @returns the updated Path2.
  5890. */
  5891. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5892. /**
  5893. * Closes the Path2.
  5894. * @returns the Path2.
  5895. */
  5896. close(): Path2;
  5897. /**
  5898. * Gets the sum of the distance between each sequential point in the path
  5899. * @returns the Path2 total length (float).
  5900. */
  5901. length(): number;
  5902. /**
  5903. * Gets the points which construct the path
  5904. * @returns the Path2 internal array of points.
  5905. */
  5906. getPoints(): Vector2[];
  5907. /**
  5908. * Retreives the point at the distance aways from the starting point
  5909. * @param normalizedLengthPosition the length along the path to retreive the point from
  5910. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5911. */
  5912. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5913. /**
  5914. * Creates a new path starting from an x and y position
  5915. * @param x starting x value
  5916. * @param y starting y value
  5917. * @returns a new Path2 starting at the coordinates (x, y).
  5918. */
  5919. static StartingAt(x: number, y: number): Path2;
  5920. }
  5921. /**
  5922. * Represents a 3D path made up of multiple 3D points
  5923. */
  5924. export class Path3D {
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[];
  5929. private _curve;
  5930. private _distances;
  5931. private _tangents;
  5932. private _normals;
  5933. private _binormals;
  5934. private _raw;
  5935. /**
  5936. * new Path3D(path, normal, raw)
  5937. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5938. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5939. * @param path an array of Vector3, the curve axis of the Path3D
  5940. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5941. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5942. */
  5943. constructor(
  5944. /**
  5945. * an array of Vector3, the curve axis of the Path3D
  5946. */
  5947. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5948. /**
  5949. * Returns the Path3D array of successive Vector3 designing its curve.
  5950. * @returns the Path3D array of successive Vector3 designing its curve.
  5951. */
  5952. getCurve(): Vector3[];
  5953. /**
  5954. * Returns an array populated with tangent vectors on each Path3D curve point.
  5955. * @returns an array populated with tangent vectors on each Path3D curve point.
  5956. */
  5957. getTangents(): Vector3[];
  5958. /**
  5959. * Returns an array populated with normal vectors on each Path3D curve point.
  5960. * @returns an array populated with normal vectors on each Path3D curve point.
  5961. */
  5962. getNormals(): Vector3[];
  5963. /**
  5964. * Returns an array populated with binormal vectors on each Path3D curve point.
  5965. * @returns an array populated with binormal vectors on each Path3D curve point.
  5966. */
  5967. getBinormals(): Vector3[];
  5968. /**
  5969. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5970. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5971. */
  5972. getDistances(): number[];
  5973. /**
  5974. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5975. * @param path path which all values are copied into the curves points
  5976. * @param firstNormal which should be projected onto the curve
  5977. * @returns the same object updated.
  5978. */
  5979. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5980. private _compute;
  5981. private _getFirstNonNullVector;
  5982. private _getLastNonNullVector;
  5983. private _normalVector;
  5984. }
  5985. /**
  5986. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5987. * A Curve3 is designed from a series of successive Vector3.
  5988. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5989. */
  5990. export class Curve3 {
  5991. private _points;
  5992. private _length;
  5993. /**
  5994. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5995. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5996. * @param v1 (Vector3) the control point
  5997. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5998. * @param nbPoints (integer) the wanted number of points in the curve
  5999. * @returns the created Curve3
  6000. */
  6001. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6002. /**
  6003. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6004. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6005. * @param v1 (Vector3) the first control point
  6006. * @param v2 (Vector3) the second control point
  6007. * @param v3 (Vector3) the end point of the Cubic Bezier
  6008. * @param nbPoints (integer) the wanted number of points in the curve
  6009. * @returns the created Curve3
  6010. */
  6011. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6012. /**
  6013. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6014. * @param p1 (Vector3) the origin point of the Hermite Spline
  6015. * @param t1 (Vector3) the tangent vector at the origin point
  6016. * @param p2 (Vector3) the end point of the Hermite Spline
  6017. * @param t2 (Vector3) the tangent vector at the end point
  6018. * @param nbPoints (integer) the wanted number of points in the curve
  6019. * @returns the created Curve3
  6020. */
  6021. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6022. /**
  6023. * Returns a Curve3 object along a CatmullRom Spline curve :
  6024. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6025. * @param nbPoints (integer) the wanted number of points between each curve control points
  6026. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6027. * @returns the created Curve3
  6028. */
  6029. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6030. /**
  6031. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6032. * A Curve3 is designed from a series of successive Vector3.
  6033. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6034. * @param points points which make up the curve
  6035. */
  6036. constructor(points: Vector3[]);
  6037. /**
  6038. * @returns the Curve3 stored array of successive Vector3
  6039. */
  6040. getPoints(): Vector3[];
  6041. /**
  6042. * @returns the computed length (float) of the curve.
  6043. */
  6044. length(): number;
  6045. /**
  6046. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6047. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6048. * curveA and curveB keep unchanged.
  6049. * @param curve the curve to continue from this curve
  6050. * @returns the newly constructed curve
  6051. */
  6052. continue(curve: DeepImmutable<Curve3>): Curve3;
  6053. private _computeLength;
  6054. }
  6055. }
  6056. declare module BABYLON {
  6057. /**
  6058. * This represents the main contract an easing function should follow.
  6059. * Easing functions are used throughout the animation system.
  6060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6061. */
  6062. export interface IEasingFunction {
  6063. /**
  6064. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6065. * of the easing function.
  6066. * The link below provides some of the most common examples of easing functions.
  6067. * @see https://easings.net/
  6068. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6069. * @returns the corresponding value on the curve defined by the easing function
  6070. */
  6071. ease(gradient: number): number;
  6072. }
  6073. /**
  6074. * Base class used for every default easing function.
  6075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6076. */
  6077. export class EasingFunction implements IEasingFunction {
  6078. /**
  6079. * Interpolation follows the mathematical formula associated with the easing function.
  6080. */
  6081. static readonly EASINGMODE_EASEIN: number;
  6082. /**
  6083. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6084. */
  6085. static readonly EASINGMODE_EASEOUT: number;
  6086. /**
  6087. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6088. */
  6089. static readonly EASINGMODE_EASEINOUT: number;
  6090. private _easingMode;
  6091. /**
  6092. * Sets the easing mode of the current function.
  6093. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6094. */
  6095. setEasingMode(easingMode: number): void;
  6096. /**
  6097. * Gets the current easing mode.
  6098. * @returns the easing mode
  6099. */
  6100. getEasingMode(): number;
  6101. /**
  6102. * @hidden
  6103. */
  6104. easeInCore(gradient: number): number;
  6105. /**
  6106. * Given an input gradient between 0 and 1, this returns the corresponding value
  6107. * of the easing function.
  6108. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6109. * @returns the corresponding value on the curve defined by the easing function
  6110. */
  6111. ease(gradient: number): number;
  6112. }
  6113. /**
  6114. * Easing function with a circle shape (see link below).
  6115. * @see https://easings.net/#easeInCirc
  6116. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6117. */
  6118. export class CircleEase extends EasingFunction implements IEasingFunction {
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a ease back shape (see link below).
  6124. * @see https://easings.net/#easeInBack
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BackEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the amplitude of the function */
  6129. amplitude: number;
  6130. /**
  6131. * Instantiates a back ease easing
  6132. * @see https://easings.net/#easeInBack
  6133. * @param amplitude Defines the amplitude of the function
  6134. */
  6135. constructor(
  6136. /** Defines the amplitude of the function */
  6137. amplitude?: number);
  6138. /** @hidden */
  6139. easeInCore(gradient: number): number;
  6140. }
  6141. /**
  6142. * Easing function with a bouncing shape (see link below).
  6143. * @see https://easings.net/#easeInBounce
  6144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6145. */
  6146. export class BounceEase extends EasingFunction implements IEasingFunction {
  6147. /** Defines the number of bounces */
  6148. bounces: number;
  6149. /** Defines the amplitude of the bounce */
  6150. bounciness: number;
  6151. /**
  6152. * Instantiates a bounce easing
  6153. * @see https://easings.net/#easeInBounce
  6154. * @param bounces Defines the number of bounces
  6155. * @param bounciness Defines the amplitude of the bounce
  6156. */
  6157. constructor(
  6158. /** Defines the number of bounces */
  6159. bounces?: number,
  6160. /** Defines the amplitude of the bounce */
  6161. bounciness?: number);
  6162. /** @hidden */
  6163. easeInCore(gradient: number): number;
  6164. }
  6165. /**
  6166. * Easing function with a power of 3 shape (see link below).
  6167. * @see https://easings.net/#easeInCubic
  6168. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6169. */
  6170. export class CubicEase extends EasingFunction implements IEasingFunction {
  6171. /** @hidden */
  6172. easeInCore(gradient: number): number;
  6173. }
  6174. /**
  6175. * Easing function with an elastic shape (see link below).
  6176. * @see https://easings.net/#easeInElastic
  6177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6178. */
  6179. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6180. /** Defines the number of oscillations*/
  6181. oscillations: number;
  6182. /** Defines the amplitude of the oscillations*/
  6183. springiness: number;
  6184. /**
  6185. * Instantiates an elastic easing function
  6186. * @see https://easings.net/#easeInElastic
  6187. * @param oscillations Defines the number of oscillations
  6188. * @param springiness Defines the amplitude of the oscillations
  6189. */
  6190. constructor(
  6191. /** Defines the number of oscillations*/
  6192. oscillations?: number,
  6193. /** Defines the amplitude of the oscillations*/
  6194. springiness?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with an exponential shape (see link below).
  6200. * @see https://easings.net/#easeInExpo
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the exponent of the function */
  6205. exponent: number;
  6206. /**
  6207. * Instantiates an exponential easing function
  6208. * @see https://easings.net/#easeInExpo
  6209. * @param exponent Defines the exponent of the function
  6210. */
  6211. constructor(
  6212. /** Defines the exponent of the function */
  6213. exponent?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class PowerEase extends EasingFunction implements IEasingFunction {
  6223. /** Defines the power of the function */
  6224. power: number;
  6225. /**
  6226. * Instantiates an power base easing function
  6227. * @see https://easings.net/#easeInQuad
  6228. * @param power Defines the power of the function
  6229. */
  6230. constructor(
  6231. /** Defines the power of the function */
  6232. power?: number);
  6233. /** @hidden */
  6234. easeInCore(gradient: number): number;
  6235. }
  6236. /**
  6237. * Easing function with a power of 2 shape (see link below).
  6238. * @see https://easings.net/#easeInQuad
  6239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6240. */
  6241. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6242. /** @hidden */
  6243. easeInCore(gradient: number): number;
  6244. }
  6245. /**
  6246. * Easing function with a power of 4 shape (see link below).
  6247. * @see https://easings.net/#easeInQuart
  6248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6249. */
  6250. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6251. /** @hidden */
  6252. easeInCore(gradient: number): number;
  6253. }
  6254. /**
  6255. * Easing function with a power of 5 shape (see link below).
  6256. * @see https://easings.net/#easeInQuint
  6257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6258. */
  6259. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a sin shape (see link below).
  6265. * @see https://easings.net/#easeInSine
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class SineEase extends EasingFunction implements IEasingFunction {
  6269. /** @hidden */
  6270. easeInCore(gradient: number): number;
  6271. }
  6272. /**
  6273. * Easing function with a bezier shape (see link below).
  6274. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6276. */
  6277. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6278. /** Defines the x component of the start tangent in the bezier curve */
  6279. x1: number;
  6280. /** Defines the y component of the start tangent in the bezier curve */
  6281. y1: number;
  6282. /** Defines the x component of the end tangent in the bezier curve */
  6283. x2: number;
  6284. /** Defines the y component of the end tangent in the bezier curve */
  6285. y2: number;
  6286. /**
  6287. * Instantiates a bezier function
  6288. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6289. * @param x1 Defines the x component of the start tangent in the bezier curve
  6290. * @param y1 Defines the y component of the start tangent in the bezier curve
  6291. * @param x2 Defines the x component of the end tangent in the bezier curve
  6292. * @param y2 Defines the y component of the end tangent in the bezier curve
  6293. */
  6294. constructor(
  6295. /** Defines the x component of the start tangent in the bezier curve */
  6296. x1?: number,
  6297. /** Defines the y component of the start tangent in the bezier curve */
  6298. y1?: number,
  6299. /** Defines the x component of the end tangent in the bezier curve */
  6300. x2?: number,
  6301. /** Defines the y component of the end tangent in the bezier curve */
  6302. y2?: number);
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. }
  6307. declare module BABYLON {
  6308. /**
  6309. * Defines an interface which represents an animation key frame
  6310. */
  6311. export interface IAnimationKey {
  6312. /**
  6313. * Frame of the key frame
  6314. */
  6315. frame: number;
  6316. /**
  6317. * Value at the specifies key frame
  6318. */
  6319. value: any;
  6320. /**
  6321. * The input tangent for the cubic hermite spline
  6322. */
  6323. inTangent?: any;
  6324. /**
  6325. * The output tangent for the cubic hermite spline
  6326. */
  6327. outTangent?: any;
  6328. /**
  6329. * The animation interpolation type
  6330. */
  6331. interpolation?: AnimationKeyInterpolation;
  6332. }
  6333. /**
  6334. * Enum for the animation key frame interpolation type
  6335. */
  6336. export enum AnimationKeyInterpolation {
  6337. /**
  6338. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6339. */
  6340. STEP = 1
  6341. }
  6342. }
  6343. declare module BABYLON {
  6344. /**
  6345. * Represents the range of an animation
  6346. */
  6347. export class AnimationRange {
  6348. /**The name of the animation range**/
  6349. name: string;
  6350. /**The starting frame of the animation */
  6351. from: number;
  6352. /**The ending frame of the animation*/
  6353. to: number;
  6354. /**
  6355. * Initializes the range of an animation
  6356. * @param name The name of the animation range
  6357. * @param from The starting frame of the animation
  6358. * @param to The ending frame of the animation
  6359. */
  6360. constructor(
  6361. /**The name of the animation range**/
  6362. name: string,
  6363. /**The starting frame of the animation */
  6364. from: number,
  6365. /**The ending frame of the animation*/
  6366. to: number);
  6367. /**
  6368. * Makes a copy of the animation range
  6369. * @returns A copy of the animation range
  6370. */
  6371. clone(): AnimationRange;
  6372. }
  6373. }
  6374. declare module BABYLON {
  6375. /**
  6376. * Composed of a frame, and an action function
  6377. */
  6378. export class AnimationEvent {
  6379. /** The frame for which the event is triggered **/
  6380. frame: number;
  6381. /** The event to perform when triggered **/
  6382. action: (currentFrame: number) => void;
  6383. /** Specifies if the event should be triggered only once**/
  6384. onlyOnce?: boolean | undefined;
  6385. /**
  6386. * Specifies if the animation event is done
  6387. */
  6388. isDone: boolean;
  6389. /**
  6390. * Initializes the animation event
  6391. * @param frame The frame for which the event is triggered
  6392. * @param action The event to perform when triggered
  6393. * @param onlyOnce Specifies if the event should be triggered only once
  6394. */
  6395. constructor(
  6396. /** The frame for which the event is triggered **/
  6397. frame: number,
  6398. /** The event to perform when triggered **/
  6399. action: (currentFrame: number) => void,
  6400. /** Specifies if the event should be triggered only once**/
  6401. onlyOnce?: boolean | undefined);
  6402. /** @hidden */
  6403. _clone(): AnimationEvent;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Interface used to define a behavior
  6409. */
  6410. export interface Behavior<T> {
  6411. /** gets or sets behavior's name */
  6412. name: string;
  6413. /**
  6414. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6415. */
  6416. init(): void;
  6417. /**
  6418. * Called when the behavior is attached to a target
  6419. * @param target defines the target where the behavior is attached to
  6420. */
  6421. attach(target: T): void;
  6422. /**
  6423. * Called when the behavior is detached from its target
  6424. */
  6425. detach(): void;
  6426. }
  6427. /**
  6428. * Interface implemented by classes supporting behaviors
  6429. */
  6430. export interface IBehaviorAware<T> {
  6431. /**
  6432. * Attach a behavior
  6433. * @param behavior defines the behavior to attach
  6434. * @returns the current host
  6435. */
  6436. addBehavior(behavior: Behavior<T>): T;
  6437. /**
  6438. * Remove a behavior from the current object
  6439. * @param behavior defines the behavior to detach
  6440. * @returns the current host
  6441. */
  6442. removeBehavior(behavior: Behavior<T>): T;
  6443. /**
  6444. * Gets a behavior using its name to search
  6445. * @param name defines the name to search
  6446. * @returns the behavior or null if not found
  6447. */
  6448. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6449. }
  6450. }
  6451. declare module BABYLON {
  6452. /**
  6453. * Defines an array and its length.
  6454. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6455. */
  6456. export interface ISmartArrayLike<T> {
  6457. /**
  6458. * The data of the array.
  6459. */
  6460. data: Array<T>;
  6461. /**
  6462. * The active length of the array.
  6463. */
  6464. length: number;
  6465. }
  6466. /**
  6467. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6468. */
  6469. export class SmartArray<T> implements ISmartArrayLike<T> {
  6470. /**
  6471. * The full set of data from the array.
  6472. */
  6473. data: Array<T>;
  6474. /**
  6475. * The active length of the array.
  6476. */
  6477. length: number;
  6478. protected _id: number;
  6479. /**
  6480. * Instantiates a Smart Array.
  6481. * @param capacity defines the default capacity of the array.
  6482. */
  6483. constructor(capacity: number);
  6484. /**
  6485. * Pushes a value at the end of the active data.
  6486. * @param value defines the object to push in the array.
  6487. */
  6488. push(value: T): void;
  6489. /**
  6490. * Iterates over the active data and apply the lambda to them.
  6491. * @param func defines the action to apply on each value.
  6492. */
  6493. forEach(func: (content: T) => void): void;
  6494. /**
  6495. * Sorts the full sets of data.
  6496. * @param compareFn defines the comparison function to apply.
  6497. */
  6498. sort(compareFn: (a: T, b: T) => number): void;
  6499. /**
  6500. * Resets the active data to an empty array.
  6501. */
  6502. reset(): void;
  6503. /**
  6504. * Releases all the data from the array as well as the array.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Concats the active data with a given array.
  6509. * @param array defines the data to concatenate with.
  6510. */
  6511. concat(array: any): void;
  6512. /**
  6513. * Returns the position of a value in the active data.
  6514. * @param value defines the value to find the index for
  6515. * @returns the index if found in the active data otherwise -1
  6516. */
  6517. indexOf(value: T): number;
  6518. /**
  6519. * Returns whether an element is part of the active data.
  6520. * @param value defines the value to look for
  6521. * @returns true if found in the active data otherwise false
  6522. */
  6523. contains(value: T): boolean;
  6524. private static _GlobalId;
  6525. }
  6526. /**
  6527. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6528. * The data in this array can only be present once
  6529. */
  6530. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6531. private _duplicateId;
  6532. /**
  6533. * Pushes a value at the end of the active data.
  6534. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6535. * @param value defines the object to push in the array.
  6536. */
  6537. push(value: T): void;
  6538. /**
  6539. * Pushes a value at the end of the active data.
  6540. * If the data is already present, it won t be added again
  6541. * @param value defines the object to push in the array.
  6542. * @returns true if added false if it was already present
  6543. */
  6544. pushNoDuplicate(value: T): boolean;
  6545. /**
  6546. * Resets the active data to an empty array.
  6547. */
  6548. reset(): void;
  6549. /**
  6550. * Concats the active data with a given array.
  6551. * This ensures no dupplicate will be present in the result.
  6552. * @param array defines the data to concatenate with.
  6553. */
  6554. concatWithNoDuplicate(array: any): void;
  6555. }
  6556. }
  6557. declare module BABYLON {
  6558. /**
  6559. * @ignore
  6560. * This is a list of all the different input types that are available in the application.
  6561. * Fo instance: ArcRotateCameraGamepadInput...
  6562. */
  6563. export var CameraInputTypes: {};
  6564. /**
  6565. * This is the contract to implement in order to create a new input class.
  6566. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6567. */
  6568. export interface ICameraInput<TCamera extends Camera> {
  6569. /**
  6570. * Defines the camera the input is attached to.
  6571. */
  6572. camera: Nullable<TCamera>;
  6573. /**
  6574. * Gets the class name of the current intput.
  6575. * @returns the class name
  6576. */
  6577. getClassName(): string;
  6578. /**
  6579. * Get the friendly name associated with the input class.
  6580. * @returns the input friendly name
  6581. */
  6582. getSimpleName(): string;
  6583. /**
  6584. * Attach the input controls to a specific dom element to get the input from.
  6585. * @param element Defines the element the controls should be listened from
  6586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6587. */
  6588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6589. /**
  6590. * Detach the current controls from the specified dom element.
  6591. * @param element Defines the element to stop listening the inputs from
  6592. */
  6593. detachControl(element: Nullable<HTMLElement>): void;
  6594. /**
  6595. * Update the current camera state depending on the inputs that have been used this frame.
  6596. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6597. */
  6598. checkInputs?: () => void;
  6599. }
  6600. /**
  6601. * Represents a map of input types to input instance or input index to input instance.
  6602. */
  6603. export interface CameraInputsMap<TCamera extends Camera> {
  6604. /**
  6605. * Accessor to the input by input type.
  6606. */
  6607. [name: string]: ICameraInput<TCamera>;
  6608. /**
  6609. * Accessor to the input by input index.
  6610. */
  6611. [idx: number]: ICameraInput<TCamera>;
  6612. }
  6613. /**
  6614. * This represents the input manager used within a camera.
  6615. * It helps dealing with all the different kind of input attached to a camera.
  6616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6617. */
  6618. export class CameraInputsManager<TCamera extends Camera> {
  6619. /**
  6620. * Defines the list of inputs attahed to the camera.
  6621. */
  6622. attached: CameraInputsMap<TCamera>;
  6623. /**
  6624. * Defines the dom element the camera is collecting inputs from.
  6625. * This is null if the controls have not been attached.
  6626. */
  6627. attachedElement: Nullable<HTMLElement>;
  6628. /**
  6629. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6630. */
  6631. noPreventDefault: boolean;
  6632. /**
  6633. * Defined the camera the input manager belongs to.
  6634. */
  6635. camera: TCamera;
  6636. /**
  6637. * Update the current camera state depending on the inputs that have been used this frame.
  6638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6639. */
  6640. checkInputs: () => void;
  6641. /**
  6642. * Instantiate a new Camera Input Manager.
  6643. * @param camera Defines the camera the input manager blongs to
  6644. */
  6645. constructor(camera: TCamera);
  6646. /**
  6647. * Add an input method to a camera
  6648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6649. * @param input camera input method
  6650. */
  6651. add(input: ICameraInput<TCamera>): void;
  6652. /**
  6653. * Remove a specific input method from a camera
  6654. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6655. * @param inputToRemove camera input method
  6656. */
  6657. remove(inputToRemove: ICameraInput<TCamera>): void;
  6658. /**
  6659. * Remove a specific input type from a camera
  6660. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6661. * @param inputType the type of the input to remove
  6662. */
  6663. removeByType(inputType: string): void;
  6664. private _addCheckInputs;
  6665. /**
  6666. * Attach the input controls to the currently attached dom element to listen the events from.
  6667. * @param input Defines the input to attach
  6668. */
  6669. attachInput(input: ICameraInput<TCamera>): void;
  6670. /**
  6671. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6672. * @param element Defines the dom element to collect the events from
  6673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6674. */
  6675. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6676. /**
  6677. * Detach the current manager inputs controls from a specific dom element.
  6678. * @param element Defines the dom element to collect the events from
  6679. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6680. */
  6681. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6682. /**
  6683. * Rebuild the dynamic inputCheck function from the current list of
  6684. * defined inputs in the manager.
  6685. */
  6686. rebuildInputCheck(): void;
  6687. /**
  6688. * Remove all attached input methods from a camera
  6689. */
  6690. clear(): void;
  6691. /**
  6692. * Serialize the current input manager attached to a camera.
  6693. * This ensures than once parsed,
  6694. * the input associated to the camera will be identical to the current ones
  6695. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6696. */
  6697. serialize(serializedCamera: any): void;
  6698. /**
  6699. * Parses an input manager serialized JSON to restore the previous list of inputs
  6700. * and states associated to a camera.
  6701. * @param parsedCamera Defines the JSON to parse
  6702. */
  6703. parse(parsedCamera: any): void;
  6704. }
  6705. }
  6706. declare module BABYLON {
  6707. /**
  6708. * @hidden
  6709. */
  6710. export class IntersectionInfo {
  6711. bu: Nullable<number>;
  6712. bv: Nullable<number>;
  6713. distance: number;
  6714. faceId: number;
  6715. subMeshId: number;
  6716. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6717. }
  6718. }
  6719. declare module BABYLON {
  6720. /**
  6721. * Represens a plane by the equation ax + by + cz + d = 0
  6722. */
  6723. export class Plane {
  6724. private static _TmpMatrix;
  6725. /**
  6726. * Normal of the plane (a,b,c)
  6727. */
  6728. normal: Vector3;
  6729. /**
  6730. * d component of the plane
  6731. */
  6732. d: number;
  6733. /**
  6734. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6735. * @param a a component of the plane
  6736. * @param b b component of the plane
  6737. * @param c c component of the plane
  6738. * @param d d component of the plane
  6739. */
  6740. constructor(a: number, b: number, c: number, d: number);
  6741. /**
  6742. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6743. */
  6744. asArray(): number[];
  6745. /**
  6746. * @returns a new plane copied from the current Plane.
  6747. */
  6748. clone(): Plane;
  6749. /**
  6750. * @returns the string "Plane".
  6751. */
  6752. getClassName(): string;
  6753. /**
  6754. * @returns the Plane hash code.
  6755. */
  6756. getHashCode(): number;
  6757. /**
  6758. * Normalize the current Plane in place.
  6759. * @returns the updated Plane.
  6760. */
  6761. normalize(): Plane;
  6762. /**
  6763. * Applies a transformation the plane and returns the result
  6764. * @param transformation the transformation matrix to be applied to the plane
  6765. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6766. */
  6767. transform(transformation: DeepImmutable<Matrix>): Plane;
  6768. /**
  6769. * Calcualtte the dot product between the point and the plane normal
  6770. * @param point point to calculate the dot product with
  6771. * @returns the dot product (float) of the point coordinates and the plane normal.
  6772. */
  6773. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6774. /**
  6775. * Updates the current Plane from the plane defined by the three given points.
  6776. * @param point1 one of the points used to contruct the plane
  6777. * @param point2 one of the points used to contruct the plane
  6778. * @param point3 one of the points used to contruct the plane
  6779. * @returns the updated Plane.
  6780. */
  6781. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6782. /**
  6783. * Checks if the plane is facing a given direction
  6784. * @param direction the direction to check if the plane is facing
  6785. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6786. * @returns True is the vector "direction" is the same side than the plane normal.
  6787. */
  6788. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6789. /**
  6790. * Calculates the distance to a point
  6791. * @param point point to calculate distance to
  6792. * @returns the signed distance (float) from the given point to the Plane.
  6793. */
  6794. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6795. /**
  6796. * Creates a plane from an array
  6797. * @param array the array to create a plane from
  6798. * @returns a new Plane from the given array.
  6799. */
  6800. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6801. /**
  6802. * Creates a plane from three points
  6803. * @param point1 point used to create the plane
  6804. * @param point2 point used to create the plane
  6805. * @param point3 point used to create the plane
  6806. * @returns a new Plane defined by the three given points.
  6807. */
  6808. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6809. /**
  6810. * Creates a plane from an origin point and a normal
  6811. * @param origin origin of the plane to be constructed
  6812. * @param normal normal of the plane to be constructed
  6813. * @returns a new Plane the normal vector to this plane at the given origin point.
  6814. * Note : the vector "normal" is updated because normalized.
  6815. */
  6816. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6817. /**
  6818. * Calculates the distance from a plane and a point
  6819. * @param origin origin of the plane to be constructed
  6820. * @param normal normal of the plane to be constructed
  6821. * @param point point to calculate distance to
  6822. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6823. */
  6824. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6825. }
  6826. }
  6827. declare module BABYLON {
  6828. /**
  6829. * Class used to store bounding sphere information
  6830. */
  6831. export class BoundingSphere {
  6832. /**
  6833. * Gets the center of the bounding sphere in local space
  6834. */
  6835. readonly center: Vector3;
  6836. /**
  6837. * Radius of the bounding sphere in local space
  6838. */
  6839. radius: number;
  6840. /**
  6841. * Gets the center of the bounding sphere in world space
  6842. */
  6843. readonly centerWorld: Vector3;
  6844. /**
  6845. * Radius of the bounding sphere in world space
  6846. */
  6847. radiusWorld: number;
  6848. /**
  6849. * Gets the minimum vector in local space
  6850. */
  6851. readonly minimum: Vector3;
  6852. /**
  6853. * Gets the maximum vector in local space
  6854. */
  6855. readonly maximum: Vector3;
  6856. private _worldMatrix;
  6857. private static readonly TmpVector3;
  6858. /**
  6859. * Creates a new bounding sphere
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding sphere by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingSphere;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding sphere is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding sphere center is in between the frustum planes.
  6893. * Used for optimistic fast inclusion.
  6894. * @param frustumPlanes defines the frustum planes to test
  6895. * @returns true if the sphere center is in between the frustum planes
  6896. */
  6897. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6898. /**
  6899. * Tests if a point is inside the bounding sphere
  6900. * @param point defines the point to test
  6901. * @returns true if the point is inside the bounding sphere
  6902. */
  6903. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6904. /**
  6905. * Checks if two sphere intersct
  6906. * @param sphere0 sphere 0
  6907. * @param sphere1 sphere 1
  6908. * @returns true if the speres intersect
  6909. */
  6910. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6911. }
  6912. }
  6913. declare module BABYLON {
  6914. /**
  6915. * Class used to store bounding box information
  6916. */
  6917. export class BoundingBox implements ICullable {
  6918. /**
  6919. * Gets the 8 vectors representing the bounding box in local space
  6920. */
  6921. readonly vectors: Vector3[];
  6922. /**
  6923. * Gets the center of the bounding box in local space
  6924. */
  6925. readonly center: Vector3;
  6926. /**
  6927. * Gets the center of the bounding box in world space
  6928. */
  6929. readonly centerWorld: Vector3;
  6930. /**
  6931. * Gets the extend size in local space
  6932. */
  6933. readonly extendSize: Vector3;
  6934. /**
  6935. * Gets the extend size in world space
  6936. */
  6937. readonly extendSizeWorld: Vector3;
  6938. /**
  6939. * Gets the OBB (object bounding box) directions
  6940. */
  6941. readonly directions: Vector3[];
  6942. /**
  6943. * Gets the 8 vectors representing the bounding box in world space
  6944. */
  6945. readonly vectorsWorld: Vector3[];
  6946. /**
  6947. * Gets the minimum vector in world space
  6948. */
  6949. readonly minimumWorld: Vector3;
  6950. /**
  6951. * Gets the maximum vector in world space
  6952. */
  6953. readonly maximumWorld: Vector3;
  6954. /**
  6955. * Gets the minimum vector in local space
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * Gets the maximum vector in local space
  6960. */
  6961. readonly maximum: Vector3;
  6962. private _worldMatrix;
  6963. private static readonly TmpVector3;
  6964. /**
  6965. * @hidden
  6966. */
  6967. _tag: number;
  6968. /**
  6969. * Creates a new bounding box
  6970. * @param min defines the minimum vector (in local space)
  6971. * @param max defines the maximum vector (in local space)
  6972. * @param worldMatrix defines the new world matrix
  6973. */
  6974. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6975. /**
  6976. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6977. * @param min defines the new minimum vector (in local space)
  6978. * @param max defines the new maximum vector (in local space)
  6979. * @param worldMatrix defines the new world matrix
  6980. */
  6981. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Scale the current bounding box by applying a scale factor
  6984. * @param factor defines the scale factor to apply
  6985. * @returns the current bounding box
  6986. */
  6987. scale(factor: number): BoundingBox;
  6988. /**
  6989. * Gets the world matrix of the bounding box
  6990. * @returns a matrix
  6991. */
  6992. getWorldMatrix(): DeepImmutable<Matrix>;
  6993. /** @hidden */
  6994. _update(world: DeepImmutable<Matrix>): void;
  6995. /**
  6996. * Tests if the bounding box is intersecting the frustum planes
  6997. * @param frustumPlanes defines the frustum planes to test
  6998. * @returns true if there is an intersection
  6999. */
  7000. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7001. /**
  7002. * Tests if the bounding box is entirely inside the frustum planes
  7003. * @param frustumPlanes defines the frustum planes to test
  7004. * @returns true if there is an inclusion
  7005. */
  7006. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7007. /**
  7008. * Tests if a point is inside the bounding box
  7009. * @param point defines the point to test
  7010. * @returns true if the point is inside the bounding box
  7011. */
  7012. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if the bounding box intersects with a bounding sphere
  7015. * @param sphere defines the sphere to test
  7016. * @returns true if there is an intersection
  7017. */
  7018. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7019. /**
  7020. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7021. * @param min defines the min vector to use
  7022. * @param max defines the max vector to use
  7023. * @returns true if there is an intersection
  7024. */
  7025. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7026. /**
  7027. * Tests if two bounding boxes are intersections
  7028. * @param box0 defines the first box to test
  7029. * @param box1 defines the second box to test
  7030. * @returns true if there is an intersection
  7031. */
  7032. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7033. /**
  7034. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7035. * @param minPoint defines the minimum vector of the bounding box
  7036. * @param maxPoint defines the maximum vector of the bounding box
  7037. * @param sphereCenter defines the sphere center
  7038. * @param sphereRadius defines the sphere radius
  7039. * @returns true if there is an intersection
  7040. */
  7041. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7042. /**
  7043. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7044. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @return true if there is an inclusion
  7047. */
  7048. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7051. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7052. * @param frustumPlanes defines the frustum planes to test
  7053. * @return true if there is an intersection
  7054. */
  7055. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7056. }
  7057. }
  7058. declare module BABYLON {
  7059. /** @hidden */
  7060. export class Collider {
  7061. /** Define if a collision was found */
  7062. collisionFound: boolean;
  7063. /**
  7064. * Define last intersection point in local space
  7065. */
  7066. intersectionPoint: Vector3;
  7067. /**
  7068. * Define last collided mesh
  7069. */
  7070. collidedMesh: Nullable<AbstractMesh>;
  7071. private _collisionPoint;
  7072. private _planeIntersectionPoint;
  7073. private _tempVector;
  7074. private _tempVector2;
  7075. private _tempVector3;
  7076. private _tempVector4;
  7077. private _edge;
  7078. private _baseToVertex;
  7079. private _destinationPoint;
  7080. private _slidePlaneNormal;
  7081. private _displacementVector;
  7082. /** @hidden */
  7083. _radius: Vector3;
  7084. /** @hidden */
  7085. _retry: number;
  7086. private _velocity;
  7087. private _basePoint;
  7088. private _epsilon;
  7089. /** @hidden */
  7090. _velocityWorldLength: number;
  7091. /** @hidden */
  7092. _basePointWorld: Vector3;
  7093. private _velocityWorld;
  7094. private _normalizedVelocity;
  7095. /** @hidden */
  7096. _initialVelocity: Vector3;
  7097. /** @hidden */
  7098. _initialPosition: Vector3;
  7099. private _nearestDistance;
  7100. private _collisionMask;
  7101. collisionMask: number;
  7102. /**
  7103. * Gets the plane normal used to compute the sliding response (in local space)
  7104. */
  7105. readonly slidePlaneNormal: Vector3;
  7106. /** @hidden */
  7107. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7108. /** @hidden */
  7109. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7110. /** @hidden */
  7111. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7112. /** @hidden */
  7113. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7114. /** @hidden */
  7115. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7116. /** @hidden */
  7117. _getResponse(pos: Vector3, vel: Vector3): void;
  7118. }
  7119. }
  7120. declare module BABYLON {
  7121. /**
  7122. * Interface for cullable objects
  7123. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7124. */
  7125. export interface ICullable {
  7126. /**
  7127. * Checks if the object or part of the object is in the frustum
  7128. * @param frustumPlanes Camera near/planes
  7129. * @returns true if the object is in frustum otherwise false
  7130. */
  7131. isInFrustum(frustumPlanes: Plane[]): boolean;
  7132. /**
  7133. * Checks if a cullable object (mesh...) is in the camera frustum
  7134. * Unlike isInFrustum this cheks the full bounding box
  7135. * @param frustumPlanes Camera near/planes
  7136. * @returns true if the object is in frustum otherwise false
  7137. */
  7138. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7139. }
  7140. /**
  7141. * Info for a bounding data of a mesh
  7142. */
  7143. export class BoundingInfo implements ICullable {
  7144. /**
  7145. * Bounding box for the mesh
  7146. */
  7147. readonly boundingBox: BoundingBox;
  7148. /**
  7149. * Bounding sphere for the mesh
  7150. */
  7151. readonly boundingSphere: BoundingSphere;
  7152. private _isLocked;
  7153. private static readonly TmpVector3;
  7154. /**
  7155. * Constructs bounding info
  7156. * @param minimum min vector of the bounding box/sphere
  7157. * @param maximum max vector of the bounding box/sphere
  7158. * @param worldMatrix defines the new world matrix
  7159. */
  7160. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7161. /**
  7162. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7163. * @param min defines the new minimum vector (in local space)
  7164. * @param max defines the new maximum vector (in local space)
  7165. * @param worldMatrix defines the new world matrix
  7166. */
  7167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7168. /**
  7169. * min vector of the bounding box/sphere
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * max vector of the bounding box/sphere
  7174. */
  7175. readonly maximum: Vector3;
  7176. /**
  7177. * If the info is locked and won't be updated to avoid perf overhead
  7178. */
  7179. isLocked: boolean;
  7180. /**
  7181. * Updates the bounding sphere and box
  7182. * @param world world matrix to be used to update
  7183. */
  7184. update(world: DeepImmutable<Matrix>): void;
  7185. /**
  7186. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7187. * @param center New center of the bounding info
  7188. * @param extend New extend of the bounding info
  7189. * @returns the current bounding info
  7190. */
  7191. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7192. /**
  7193. * Scale the current bounding info by applying a scale factor
  7194. * @param factor defines the scale factor to apply
  7195. * @returns the current bounding info
  7196. */
  7197. scale(factor: number): BoundingInfo;
  7198. /**
  7199. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7200. * @param frustumPlanes defines the frustum to test
  7201. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7202. * @returns true if the bounding info is in the frustum planes
  7203. */
  7204. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7205. /**
  7206. * Gets the world distance between the min and max points of the bounding box
  7207. */
  7208. readonly diagonalLength: number;
  7209. /**
  7210. * Checks if a cullable object (mesh...) is in the camera frustum
  7211. * Unlike isInFrustum this cheks the full bounding box
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7216. /** @hidden */
  7217. _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Extracts minimum and maximum values from a list of indexed positions
  7238. * @param positions defines the positions to use
  7239. * @param indices defines the indices to the positions
  7240. * @param indexStart defines the start index
  7241. * @param indexCount defines the end index
  7242. * @param bias defines bias value to add to the result
  7243. * @return minimum and maximum values
  7244. */
  7245. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7246. minimum: Vector3;
  7247. maximum: Vector3;
  7248. };
  7249. /**
  7250. * Extracts minimum and maximum values from a list of positions
  7251. * @param positions defines the positions to use
  7252. * @param start defines the start index in the positions array
  7253. * @param count defines the number of positions to handle
  7254. * @param bias defines bias value to add to the result
  7255. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7256. * @return minimum and maximum values
  7257. */
  7258. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7259. minimum: Vector3;
  7260. maximum: Vector3;
  7261. };
  7262. }
  7263. declare module BABYLON {
  7264. /**
  7265. * Enum that determines the text-wrapping mode to use.
  7266. */
  7267. export enum InspectableType {
  7268. /**
  7269. * Checkbox for booleans
  7270. */
  7271. Checkbox = 0,
  7272. /**
  7273. * Sliders for numbers
  7274. */
  7275. Slider = 1,
  7276. /**
  7277. * Vector3
  7278. */
  7279. Vector3 = 2,
  7280. /**
  7281. * Quaternions
  7282. */
  7283. Quaternion = 3,
  7284. /**
  7285. * Color3
  7286. */
  7287. Color3 = 4,
  7288. /**
  7289. * String
  7290. */
  7291. String = 5
  7292. }
  7293. /**
  7294. * Interface used to define custom inspectable properties.
  7295. * This interface is used by the inspector to display custom property grids
  7296. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7297. */
  7298. export interface IInspectable {
  7299. /**
  7300. * Gets the label to display
  7301. */
  7302. label: string;
  7303. /**
  7304. * Gets the name of the property to edit
  7305. */
  7306. propertyName: string;
  7307. /**
  7308. * Gets the type of the editor to use
  7309. */
  7310. type: InspectableType;
  7311. /**
  7312. * Gets the minimum value of the property when using in "slider" mode
  7313. */
  7314. min?: number;
  7315. /**
  7316. * Gets the maximum value of the property when using in "slider" mode
  7317. */
  7318. max?: number;
  7319. /**
  7320. * Gets the setp to use when using in "slider" mode
  7321. */
  7322. step?: number;
  7323. }
  7324. }
  7325. declare module BABYLON {
  7326. /**
  7327. * Class used to provide helper for timing
  7328. */
  7329. export class TimingTools {
  7330. /**
  7331. * Polyfill for setImmediate
  7332. * @param action defines the action to execute after the current execution block
  7333. */
  7334. static SetImmediate(action: () => void): void;
  7335. }
  7336. }
  7337. declare module BABYLON {
  7338. /**
  7339. * Class used to enable instatition of objects by class name
  7340. */
  7341. export class InstantiationTools {
  7342. /**
  7343. * Use this object to register external classes like custom textures or material
  7344. * to allow the laoders to instantiate them
  7345. */
  7346. static RegisteredExternalClasses: {
  7347. [key: string]: Object;
  7348. };
  7349. /**
  7350. * Tries to instantiate a new object from a given class name
  7351. * @param className defines the class name to instantiate
  7352. * @returns the new object or null if the system was not able to do the instantiation
  7353. */
  7354. static Instantiate(className: string): any;
  7355. }
  7356. }
  7357. declare module BABYLON {
  7358. /**
  7359. * This represents the required contract to create a new type of texture loader.
  7360. */
  7361. export interface IInternalTextureLoader {
  7362. /**
  7363. * Defines wether the loader supports cascade loading the different faces.
  7364. */
  7365. supportCascades: boolean;
  7366. /**
  7367. * This returns if the loader support the current file information.
  7368. * @param extension defines the file extension of the file being loaded
  7369. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7370. * @param fallback defines the fallback internal texture if any
  7371. * @param isBase64 defines whether the texture is encoded as a base64
  7372. * @param isBuffer defines whether the texture data are stored as a buffer
  7373. * @returns true if the loader can load the specified file
  7374. */
  7375. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7376. /**
  7377. * Transform the url before loading if required.
  7378. * @param rootUrl the url of the texture
  7379. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7380. * @returns the transformed texture
  7381. */
  7382. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7383. /**
  7384. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7385. * @param rootUrl the url of the texture
  7386. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7387. * @returns the fallback texture
  7388. */
  7389. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7390. /**
  7391. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7392. * @param data contains the texture data
  7393. * @param texture defines the BabylonJS internal texture
  7394. * @param createPolynomials will be true if polynomials have been requested
  7395. * @param onLoad defines the callback to trigger once the texture is ready
  7396. * @param onError defines the callback to trigger in case of error
  7397. */
  7398. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7399. /**
  7400. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7401. * @param data contains the texture data
  7402. * @param texture defines the BabylonJS internal texture
  7403. * @param callback defines the method to call once ready to upload
  7404. */
  7405. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7406. }
  7407. }
  7408. declare module BABYLON {
  7409. interface Engine {
  7410. /**
  7411. * Creates a depth stencil cube texture.
  7412. * This is only available in WebGL 2.
  7413. * @param size The size of face edge in the cube texture.
  7414. * @param options The options defining the cube texture.
  7415. * @returns The cube texture
  7416. */
  7417. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7418. /**
  7419. * Creates a cube texture
  7420. * @param rootUrl defines the url where the files to load is located
  7421. * @param scene defines the current scene
  7422. * @param files defines the list of files to load (1 per face)
  7423. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7424. * @param onLoad defines an optional callback raised when the texture is loaded
  7425. * @param onError defines an optional callback raised if there is an issue to load the texture
  7426. * @param format defines the format of the data
  7427. * @param forcedExtension defines the extension to use to pick the right loader
  7428. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7429. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7430. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7431. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7432. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7433. * @returns the cube texture as an InternalTexture
  7434. */
  7435. 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;
  7436. /**
  7437. * Creates a cube texture
  7438. * @param rootUrl defines the url where the files to load is located
  7439. * @param scene defines the current scene
  7440. * @param files defines the list of files to load (1 per face)
  7441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7442. * @param onLoad defines an optional callback raised when the texture is loaded
  7443. * @param onError defines an optional callback raised if there is an issue to load the texture
  7444. * @param format defines the format of the data
  7445. * @param forcedExtension defines the extension to use to pick the right loader
  7446. * @returns the cube texture as an InternalTexture
  7447. */
  7448. 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;
  7449. /**
  7450. * Creates a cube texture
  7451. * @param rootUrl defines the url where the files to load is located
  7452. * @param scene defines the current scene
  7453. * @param files defines the list of files to load (1 per face)
  7454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7455. * @param onLoad defines an optional callback raised when the texture is loaded
  7456. * @param onError defines an optional callback raised if there is an issue to load the texture
  7457. * @param format defines the format of the data
  7458. * @param forcedExtension defines the extension to use to pick the right loader
  7459. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7460. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7461. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7462. * @returns the cube texture as an InternalTexture
  7463. */
  7464. 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;
  7465. /** @hidden */
  7466. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7467. /** @hidden */
  7468. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7469. /** @hidden */
  7470. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7471. /** @hidden */
  7472. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7473. }
  7474. }
  7475. declare module BABYLON {
  7476. /**
  7477. * Class for creating a cube texture
  7478. */
  7479. export class CubeTexture extends BaseTexture {
  7480. private _delayedOnLoad;
  7481. /**
  7482. * The url of the texture
  7483. */
  7484. url: string;
  7485. /**
  7486. * Gets or sets the center of the bounding box associated with the cube texture.
  7487. * It must define where the camera used to render the texture was set
  7488. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7489. */
  7490. boundingBoxPosition: Vector3;
  7491. private _boundingBoxSize;
  7492. /**
  7493. * Gets or sets the size of the bounding box associated with the cube texture
  7494. * When defined, the cubemap will switch to local mode
  7495. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7496. * @example https://www.babylonjs-playground.com/#RNASML
  7497. */
  7498. /**
  7499. * Returns the bounding box size
  7500. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7501. */
  7502. boundingBoxSize: Vector3;
  7503. protected _rotationY: number;
  7504. /**
  7505. * Sets texture matrix rotation angle around Y axis in radians.
  7506. */
  7507. /**
  7508. * Gets texture matrix rotation angle around Y axis radians.
  7509. */
  7510. rotationY: number;
  7511. /**
  7512. * Are mip maps generated for this texture or not.
  7513. */
  7514. readonly noMipmap: boolean;
  7515. private _noMipmap;
  7516. private _files;
  7517. private _extensions;
  7518. private _textureMatrix;
  7519. private _format;
  7520. private _createPolynomials;
  7521. /** @hidden */
  7522. _prefiltered: boolean;
  7523. /**
  7524. * Creates a cube texture from an array of image urls
  7525. * @param files defines an array of image urls
  7526. * @param scene defines the hosting scene
  7527. * @param noMipmap specifies if mip maps are not used
  7528. * @returns a cube texture
  7529. */
  7530. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7531. /**
  7532. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7533. * @param url defines the url of the prefiltered texture
  7534. * @param scene defines the scene the texture is attached to
  7535. * @param forcedExtension defines the extension of the file if different from the url
  7536. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7537. * @return the prefiltered texture
  7538. */
  7539. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7540. /**
  7541. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7542. * as prefiltered data.
  7543. * @param rootUrl defines the url of the texture or the root name of the six images
  7544. * @param scene defines the scene the texture is attached to
  7545. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7546. * @param noMipmap defines if mipmaps should be created or not
  7547. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7548. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7549. * @param onError defines a callback triggered in case of error during load
  7550. * @param format defines the internal format to use for the texture once loaded
  7551. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7552. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7553. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7556. * @return the cube texture
  7557. */
  7558. 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);
  7559. /**
  7560. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7561. */
  7562. readonly isPrefiltered: boolean;
  7563. /**
  7564. * Get the current class name of the texture useful for serialization or dynamic coding.
  7565. * @returns "CubeTexture"
  7566. */
  7567. getClassName(): string;
  7568. /**
  7569. * Update the url (and optional buffer) of this texture if url was null during construction.
  7570. * @param url the url of the texture
  7571. * @param forcedExtension defines the extension to use
  7572. * @param onLoad callback called when the texture is loaded (defaults to null)
  7573. */
  7574. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7575. /**
  7576. * Delays loading of the cube texture
  7577. * @param forcedExtension defines the extension to use
  7578. */
  7579. delayLoad(forcedExtension?: string): void;
  7580. /**
  7581. * Returns the reflection texture matrix
  7582. * @returns the reflection texture matrix
  7583. */
  7584. getReflectionTextureMatrix(): Matrix;
  7585. /**
  7586. * Sets the reflection texture matrix
  7587. * @param value Reflection texture matrix
  7588. */
  7589. setReflectionTextureMatrix(value: Matrix): void;
  7590. /**
  7591. * Parses text to create a cube texture
  7592. * @param parsedTexture define the serialized text to read from
  7593. * @param scene defines the hosting scene
  7594. * @param rootUrl defines the root url of the cube texture
  7595. * @returns a cube texture
  7596. */
  7597. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7598. /**
  7599. * Makes a clone, or deep copy, of the cube texture
  7600. * @returns a new cube texture
  7601. */
  7602. clone(): CubeTexture;
  7603. }
  7604. }
  7605. declare module BABYLON {
  7606. /**
  7607. * Manages the defines for the Material
  7608. */
  7609. export class MaterialDefines {
  7610. /** @hidden */
  7611. protected _keys: string[];
  7612. private _isDirty;
  7613. /** @hidden */
  7614. _renderId: number;
  7615. /** @hidden */
  7616. _areLightsDirty: boolean;
  7617. /** @hidden */
  7618. _areLightsDisposed: boolean;
  7619. /** @hidden */
  7620. _areAttributesDirty: boolean;
  7621. /** @hidden */
  7622. _areTexturesDirty: boolean;
  7623. /** @hidden */
  7624. _areFresnelDirty: boolean;
  7625. /** @hidden */
  7626. _areMiscDirty: boolean;
  7627. /** @hidden */
  7628. _areImageProcessingDirty: boolean;
  7629. /** @hidden */
  7630. _normals: boolean;
  7631. /** @hidden */
  7632. _uvs: boolean;
  7633. /** @hidden */
  7634. _needNormals: boolean;
  7635. /** @hidden */
  7636. _needUVs: boolean;
  7637. [id: string]: any;
  7638. /**
  7639. * Specifies if the material needs to be re-calculated
  7640. */
  7641. readonly isDirty: boolean;
  7642. /**
  7643. * Marks the material to indicate that it has been re-calculated
  7644. */
  7645. markAsProcessed(): void;
  7646. /**
  7647. * Marks the material to indicate that it needs to be re-calculated
  7648. */
  7649. markAsUnprocessed(): void;
  7650. /**
  7651. * Marks the material to indicate all of its defines need to be re-calculated
  7652. */
  7653. markAllAsDirty(): void;
  7654. /**
  7655. * Marks the material to indicate that image processing needs to be re-calculated
  7656. */
  7657. markAsImageProcessingDirty(): void;
  7658. /**
  7659. * Marks the material to indicate the lights need to be re-calculated
  7660. * @param disposed Defines whether the light is dirty due to dispose or not
  7661. */
  7662. markAsLightDirty(disposed?: boolean): void;
  7663. /**
  7664. * Marks the attribute state as changed
  7665. */
  7666. markAsAttributesDirty(): void;
  7667. /**
  7668. * Marks the texture state as changed
  7669. */
  7670. markAsTexturesDirty(): void;
  7671. /**
  7672. * Marks the fresnel state as changed
  7673. */
  7674. markAsFresnelDirty(): void;
  7675. /**
  7676. * Marks the misc state as changed
  7677. */
  7678. markAsMiscDirty(): void;
  7679. /**
  7680. * Rebuilds the material defines
  7681. */
  7682. rebuild(): void;
  7683. /**
  7684. * Specifies if two material defines are equal
  7685. * @param other - A material define instance to compare to
  7686. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7687. */
  7688. isEqual(other: MaterialDefines): boolean;
  7689. /**
  7690. * Clones this instance's defines to another instance
  7691. * @param other - material defines to clone values to
  7692. */
  7693. cloneTo(other: MaterialDefines): void;
  7694. /**
  7695. * Resets the material define values
  7696. */
  7697. reset(): void;
  7698. /**
  7699. * Converts the material define values to a string
  7700. * @returns - String of material define information
  7701. */
  7702. toString(): string;
  7703. }
  7704. }
  7705. declare module BABYLON {
  7706. /**
  7707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7709. * 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;
  7710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7711. */
  7712. export class ColorCurves {
  7713. private _dirty;
  7714. private _tempColor;
  7715. private _globalCurve;
  7716. private _highlightsCurve;
  7717. private _midtonesCurve;
  7718. private _shadowsCurve;
  7719. private _positiveCurve;
  7720. private _negativeCurve;
  7721. private _globalHue;
  7722. private _globalDensity;
  7723. private _globalSaturation;
  7724. private _globalExposure;
  7725. /**
  7726. * Gets the global Hue value.
  7727. * 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).
  7728. */
  7729. /**
  7730. * Sets the global Hue value.
  7731. * 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).
  7732. */
  7733. globalHue: number;
  7734. /**
  7735. * Gets the global Density value.
  7736. * 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.
  7737. * Values less than zero provide a filter of opposite hue.
  7738. */
  7739. /**
  7740. * Sets the global Density value.
  7741. * 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.
  7742. * Values less than zero provide a filter of opposite hue.
  7743. */
  7744. globalDensity: number;
  7745. /**
  7746. * Gets the global Saturation value.
  7747. * 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.
  7748. */
  7749. /**
  7750. * Sets the global Saturation value.
  7751. * 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.
  7752. */
  7753. globalSaturation: number;
  7754. /**
  7755. * Gets the global Exposure value.
  7756. * 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.
  7757. */
  7758. /**
  7759. * Sets the global Exposure value.
  7760. * 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.
  7761. */
  7762. globalExposure: number;
  7763. private _highlightsHue;
  7764. private _highlightsDensity;
  7765. private _highlightsSaturation;
  7766. private _highlightsExposure;
  7767. /**
  7768. * Gets the highlights Hue value.
  7769. * 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).
  7770. */
  7771. /**
  7772. * Sets the highlights Hue value.
  7773. * 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).
  7774. */
  7775. highlightsHue: number;
  7776. /**
  7777. * Gets the highlights Density value.
  7778. * 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.
  7779. * Values less than zero provide a filter of opposite hue.
  7780. */
  7781. /**
  7782. * Sets the highlights Density value.
  7783. * 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.
  7784. * Values less than zero provide a filter of opposite hue.
  7785. */
  7786. highlightsDensity: number;
  7787. /**
  7788. * Gets the highlights Saturation value.
  7789. * 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.
  7790. */
  7791. /**
  7792. * Sets the highlights Saturation value.
  7793. * 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.
  7794. */
  7795. highlightsSaturation: number;
  7796. /**
  7797. * Gets the highlights Exposure value.
  7798. * 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.
  7799. */
  7800. /**
  7801. * Sets the highlights Exposure value.
  7802. * 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.
  7803. */
  7804. highlightsExposure: number;
  7805. private _midtonesHue;
  7806. private _midtonesDensity;
  7807. private _midtonesSaturation;
  7808. private _midtonesExposure;
  7809. /**
  7810. * Gets the midtones Hue value.
  7811. * 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).
  7812. */
  7813. /**
  7814. * Sets the midtones Hue value.
  7815. * 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).
  7816. */
  7817. midtonesHue: number;
  7818. /**
  7819. * Gets the midtones Density value.
  7820. * 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.
  7821. * Values less than zero provide a filter of opposite hue.
  7822. */
  7823. /**
  7824. * Sets the midtones Density value.
  7825. * 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.
  7826. * Values less than zero provide a filter of opposite hue.
  7827. */
  7828. midtonesDensity: number;
  7829. /**
  7830. * Gets the midtones Saturation value.
  7831. * 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.
  7832. */
  7833. /**
  7834. * Sets the midtones Saturation value.
  7835. * 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.
  7836. */
  7837. midtonesSaturation: number;
  7838. /**
  7839. * Gets the midtones Exposure value.
  7840. * 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.
  7841. */
  7842. /**
  7843. * Sets the midtones Exposure value.
  7844. * 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.
  7845. */
  7846. midtonesExposure: number;
  7847. private _shadowsHue;
  7848. private _shadowsDensity;
  7849. private _shadowsSaturation;
  7850. private _shadowsExposure;
  7851. /**
  7852. * Gets the shadows Hue value.
  7853. * 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).
  7854. */
  7855. /**
  7856. * Sets the shadows Hue value.
  7857. * 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).
  7858. */
  7859. shadowsHue: number;
  7860. /**
  7861. * Gets the shadows Density value.
  7862. * 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.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. /**
  7866. * Sets the shadows Density value.
  7867. * 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.
  7868. * Values less than zero provide a filter of opposite hue.
  7869. */
  7870. shadowsDensity: number;
  7871. /**
  7872. * Gets the shadows Saturation value.
  7873. * 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.
  7874. */
  7875. /**
  7876. * Sets the shadows Saturation value.
  7877. * 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.
  7878. */
  7879. shadowsSaturation: number;
  7880. /**
  7881. * Gets the shadows Exposure value.
  7882. * 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.
  7883. */
  7884. /**
  7885. * Sets the shadows Exposure value.
  7886. * 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.
  7887. */
  7888. shadowsExposure: number;
  7889. /**
  7890. * Returns the class name
  7891. * @returns The class name
  7892. */
  7893. getClassName(): string;
  7894. /**
  7895. * Binds the color curves to the shader.
  7896. * @param colorCurves The color curve to bind
  7897. * @param effect The effect to bind to
  7898. * @param positiveUniform The positive uniform shader parameter
  7899. * @param neutralUniform The neutral uniform shader parameter
  7900. * @param negativeUniform The negative uniform shader parameter
  7901. */
  7902. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7903. /**
  7904. * Prepare the list of uniforms associated with the ColorCurves effects.
  7905. * @param uniformsList The list of uniforms used in the effect
  7906. */
  7907. static PrepareUniforms(uniformsList: string[]): void;
  7908. /**
  7909. * Returns color grading data based on a hue, density, saturation and exposure value.
  7910. * @param filterHue The hue of the color filter.
  7911. * @param filterDensity The density of the color filter.
  7912. * @param saturation The saturation.
  7913. * @param exposure The exposure.
  7914. * @param result The result data container.
  7915. */
  7916. private getColorGradingDataToRef;
  7917. /**
  7918. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7919. * @param value The input slider value in range [-100,100].
  7920. * @returns Adjusted value.
  7921. */
  7922. private static applyColorGradingSliderNonlinear;
  7923. /**
  7924. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7925. * @param hue The hue (H) input.
  7926. * @param saturation The saturation (S) input.
  7927. * @param brightness The brightness (B) input.
  7928. * @result An RGBA color represented as Vector4.
  7929. */
  7930. private static fromHSBToRef;
  7931. /**
  7932. * Returns a value clamped between min and max
  7933. * @param value The value to clamp
  7934. * @param min The minimum of value
  7935. * @param max The maximum of value
  7936. * @returns The clamped value.
  7937. */
  7938. private static clamp;
  7939. /**
  7940. * Clones the current color curve instance.
  7941. * @return The cloned curves
  7942. */
  7943. clone(): ColorCurves;
  7944. /**
  7945. * Serializes the current color curve instance to a json representation.
  7946. * @return a JSON representation
  7947. */
  7948. serialize(): any;
  7949. /**
  7950. * Parses the color curve from a json representation.
  7951. * @param source the JSON source to parse
  7952. * @return The parsed curves
  7953. */
  7954. static Parse(source: any): ColorCurves;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Interface to follow in your material defines to integrate easily the
  7960. * Image proccessing functions.
  7961. * @hidden
  7962. */
  7963. export interface IImageProcessingConfigurationDefines {
  7964. IMAGEPROCESSING: boolean;
  7965. VIGNETTE: boolean;
  7966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7967. VIGNETTEBLENDMODEOPAQUE: boolean;
  7968. TONEMAPPING: boolean;
  7969. TONEMAPPING_ACES: boolean;
  7970. CONTRAST: boolean;
  7971. EXPOSURE: boolean;
  7972. COLORCURVES: boolean;
  7973. COLORGRADING: boolean;
  7974. COLORGRADING3D: boolean;
  7975. SAMPLER3DGREENDEPTH: boolean;
  7976. SAMPLER3DBGRMAP: boolean;
  7977. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7978. }
  7979. /**
  7980. * @hidden
  7981. */
  7982. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7983. IMAGEPROCESSING: boolean;
  7984. VIGNETTE: boolean;
  7985. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7986. VIGNETTEBLENDMODEOPAQUE: boolean;
  7987. TONEMAPPING: boolean;
  7988. TONEMAPPING_ACES: boolean;
  7989. CONTRAST: boolean;
  7990. COLORCURVES: boolean;
  7991. COLORGRADING: boolean;
  7992. COLORGRADING3D: boolean;
  7993. SAMPLER3DGREENDEPTH: boolean;
  7994. SAMPLER3DBGRMAP: boolean;
  7995. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7996. EXPOSURE: boolean;
  7997. constructor();
  7998. }
  7999. /**
  8000. * This groups together the common properties used for image processing either in direct forward pass
  8001. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8002. * or not.
  8003. */
  8004. export class ImageProcessingConfiguration {
  8005. /**
  8006. * Default tone mapping applied in BabylonJS.
  8007. */
  8008. static readonly TONEMAPPING_STANDARD: number;
  8009. /**
  8010. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8011. * to other engines rendering to increase portability.
  8012. */
  8013. static readonly TONEMAPPING_ACES: number;
  8014. /**
  8015. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8016. */
  8017. colorCurves: Nullable<ColorCurves>;
  8018. private _colorCurvesEnabled;
  8019. /**
  8020. * Gets wether the color curves effect is enabled.
  8021. */
  8022. /**
  8023. * Sets wether the color curves effect is enabled.
  8024. */
  8025. colorCurvesEnabled: boolean;
  8026. private _colorGradingTexture;
  8027. /**
  8028. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8029. */
  8030. /**
  8031. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8032. */
  8033. colorGradingTexture: Nullable<BaseTexture>;
  8034. private _colorGradingEnabled;
  8035. /**
  8036. * Gets wether the color grading effect is enabled.
  8037. */
  8038. /**
  8039. * Sets wether the color grading effect is enabled.
  8040. */
  8041. colorGradingEnabled: boolean;
  8042. private _colorGradingWithGreenDepth;
  8043. /**
  8044. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8045. */
  8046. /**
  8047. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8048. */
  8049. colorGradingWithGreenDepth: boolean;
  8050. private _colorGradingBGR;
  8051. /**
  8052. * Gets wether the color grading texture contains BGR values.
  8053. */
  8054. /**
  8055. * Sets wether the color grading texture contains BGR values.
  8056. */
  8057. colorGradingBGR: boolean;
  8058. /** @hidden */
  8059. _exposure: number;
  8060. /**
  8061. * Gets the Exposure used in the effect.
  8062. */
  8063. /**
  8064. * Sets the Exposure used in the effect.
  8065. */
  8066. exposure: number;
  8067. private _toneMappingEnabled;
  8068. /**
  8069. * Gets wether the tone mapping effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the tone mapping effect is enabled.
  8073. */
  8074. toneMappingEnabled: boolean;
  8075. private _toneMappingType;
  8076. /**
  8077. * Gets the type of tone mapping effect.
  8078. */
  8079. /**
  8080. * Sets the type of tone mapping effect used in BabylonJS.
  8081. */
  8082. toneMappingType: number;
  8083. protected _contrast: number;
  8084. /**
  8085. * Gets the contrast used in the effect.
  8086. */
  8087. /**
  8088. * Sets the contrast used in the effect.
  8089. */
  8090. contrast: number;
  8091. /**
  8092. * Vignette stretch size.
  8093. */
  8094. vignetteStretch: number;
  8095. /**
  8096. * Vignette centre X Offset.
  8097. */
  8098. vignetteCentreX: number;
  8099. /**
  8100. * Vignette centre Y Offset.
  8101. */
  8102. vignetteCentreY: number;
  8103. /**
  8104. * Vignette weight or intensity of the vignette effect.
  8105. */
  8106. vignetteWeight: number;
  8107. /**
  8108. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8109. * if vignetteEnabled is set to true.
  8110. */
  8111. vignetteColor: Color4;
  8112. /**
  8113. * Camera field of view used by the Vignette effect.
  8114. */
  8115. vignetteCameraFov: number;
  8116. private _vignetteBlendMode;
  8117. /**
  8118. * Gets the vignette blend mode allowing different kind of effect.
  8119. */
  8120. /**
  8121. * Sets the vignette blend mode allowing different kind of effect.
  8122. */
  8123. vignetteBlendMode: number;
  8124. private _vignetteEnabled;
  8125. /**
  8126. * Gets wether the vignette effect is enabled.
  8127. */
  8128. /**
  8129. * Sets wether the vignette effect is enabled.
  8130. */
  8131. vignetteEnabled: boolean;
  8132. private _applyByPostProcess;
  8133. /**
  8134. * Gets wether the image processing is applied through a post process or not.
  8135. */
  8136. /**
  8137. * Sets wether the image processing is applied through a post process or not.
  8138. */
  8139. applyByPostProcess: boolean;
  8140. private _isEnabled;
  8141. /**
  8142. * Gets wether the image processing is enabled or not.
  8143. */
  8144. /**
  8145. * Sets wether the image processing is enabled or not.
  8146. */
  8147. isEnabled: boolean;
  8148. /**
  8149. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8150. */
  8151. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8152. /**
  8153. * Method called each time the image processing information changes requires to recompile the effect.
  8154. */
  8155. protected _updateParameters(): void;
  8156. /**
  8157. * Gets the current class name.
  8158. * @return "ImageProcessingConfiguration"
  8159. */
  8160. getClassName(): string;
  8161. /**
  8162. * Prepare the list of uniforms associated with the Image Processing effects.
  8163. * @param uniforms The list of uniforms used in the effect
  8164. * @param defines the list of defines currently in use
  8165. */
  8166. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8167. /**
  8168. * Prepare the list of samplers associated with the Image Processing effects.
  8169. * @param samplersList The list of uniforms used in the effect
  8170. * @param defines the list of defines currently in use
  8171. */
  8172. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8173. /**
  8174. * Prepare the list of defines associated to the shader.
  8175. * @param defines the list of defines to complete
  8176. * @param forPostProcess Define if we are currently in post process mode or not
  8177. */
  8178. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8179. /**
  8180. * Returns true if all the image processing information are ready.
  8181. * @returns True if ready, otherwise, false
  8182. */
  8183. isReady(): boolean;
  8184. /**
  8185. * Binds the image processing to the shader.
  8186. * @param effect The effect to bind to
  8187. * @param aspectRatio Define the current aspect ratio of the effect
  8188. */
  8189. bind(effect: Effect, aspectRatio?: number): void;
  8190. /**
  8191. * Clones the current image processing instance.
  8192. * @return The cloned image processing
  8193. */
  8194. clone(): ImageProcessingConfiguration;
  8195. /**
  8196. * Serializes the current image processing instance to a json representation.
  8197. * @return a JSON representation
  8198. */
  8199. serialize(): any;
  8200. /**
  8201. * Parses the image processing from a json representation.
  8202. * @param source the JSON source to parse
  8203. * @return The parsed image processing
  8204. */
  8205. static Parse(source: any): ImageProcessingConfiguration;
  8206. private static _VIGNETTEMODE_MULTIPLY;
  8207. private static _VIGNETTEMODE_OPAQUE;
  8208. /**
  8209. * Used to apply the vignette as a mix with the pixel color.
  8210. */
  8211. static readonly VIGNETTEMODE_MULTIPLY: number;
  8212. /**
  8213. * Used to apply the vignette as a replacement of the pixel color.
  8214. */
  8215. static readonly VIGNETTEMODE_OPAQUE: number;
  8216. }
  8217. }
  8218. declare module BABYLON {
  8219. /** @hidden */
  8220. export var postprocessVertexShader: {
  8221. name: string;
  8222. shader: string;
  8223. };
  8224. }
  8225. declare module BABYLON {
  8226. /** Defines supported spaces */
  8227. export enum Space {
  8228. /** Local (object) space */
  8229. LOCAL = 0,
  8230. /** World space */
  8231. WORLD = 1,
  8232. /** Bone space */
  8233. BONE = 2
  8234. }
  8235. /** Defines the 3 main axes */
  8236. export class Axis {
  8237. /** X axis */
  8238. static X: Vector3;
  8239. /** Y axis */
  8240. static Y: Vector3;
  8241. /** Z axis */
  8242. static Z: Vector3;
  8243. }
  8244. }
  8245. declare module BABYLON {
  8246. /**
  8247. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8248. * This is the base of the follow, arc rotate cameras and Free camera
  8249. * @see http://doc.babylonjs.com/features/cameras
  8250. */
  8251. export class TargetCamera extends Camera {
  8252. private static _RigCamTransformMatrix;
  8253. private static _TargetTransformMatrix;
  8254. private static _TargetFocalPoint;
  8255. /**
  8256. * Define the current direction the camera is moving to
  8257. */
  8258. cameraDirection: Vector3;
  8259. /**
  8260. * Define the current rotation the camera is rotating to
  8261. */
  8262. cameraRotation: Vector2;
  8263. /**
  8264. * When set, the up vector of the camera will be updated by the rotation of the camera
  8265. */
  8266. updateUpVectorFromRotation: boolean;
  8267. private _tmpQuaternion;
  8268. /**
  8269. * Define the current rotation of the camera
  8270. */
  8271. rotation: Vector3;
  8272. /**
  8273. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8274. */
  8275. rotationQuaternion: Quaternion;
  8276. /**
  8277. * Define the current speed of the camera
  8278. */
  8279. speed: number;
  8280. /**
  8281. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8282. * around all axis.
  8283. */
  8284. noRotationConstraint: boolean;
  8285. /**
  8286. * Define the current target of the camera as an object or a position.
  8287. */
  8288. lockedTarget: any;
  8289. /** @hidden */
  8290. _currentTarget: Vector3;
  8291. /** @hidden */
  8292. _initialFocalDistance: number;
  8293. /** @hidden */
  8294. _viewMatrix: Matrix;
  8295. /** @hidden */
  8296. _camMatrix: Matrix;
  8297. /** @hidden */
  8298. _cameraTransformMatrix: Matrix;
  8299. /** @hidden */
  8300. _cameraRotationMatrix: Matrix;
  8301. /** @hidden */
  8302. _referencePoint: Vector3;
  8303. /** @hidden */
  8304. _transformedReferencePoint: Vector3;
  8305. protected _globalCurrentTarget: Vector3;
  8306. protected _globalCurrentUpVector: Vector3;
  8307. /** @hidden */
  8308. _reset: () => void;
  8309. private _defaultUp;
  8310. /**
  8311. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8312. * This is the base of the follow, arc rotate cameras and Free camera
  8313. * @see http://doc.babylonjs.com/features/cameras
  8314. * @param name Defines the name of the camera in the scene
  8315. * @param position Defines the start position of the camera in the scene
  8316. * @param scene Defines the scene the camera belongs to
  8317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8318. */
  8319. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8320. /**
  8321. * Gets the position in front of the camera at a given distance.
  8322. * @param distance The distance from the camera we want the position to be
  8323. * @returns the position
  8324. */
  8325. getFrontPosition(distance: number): Vector3;
  8326. /** @hidden */
  8327. _getLockedTargetPosition(): Nullable<Vector3>;
  8328. private _storedPosition;
  8329. private _storedRotation;
  8330. private _storedRotationQuaternion;
  8331. /**
  8332. * Store current camera state of the camera (fov, position, rotation, etc..)
  8333. * @returns the camera
  8334. */
  8335. storeState(): Camera;
  8336. /**
  8337. * Restored camera state. You must call storeState() first
  8338. * @returns whether it was successful or not
  8339. * @hidden
  8340. */
  8341. _restoreStateValues(): boolean;
  8342. /** @hidden */
  8343. _initCache(): void;
  8344. /** @hidden */
  8345. _updateCache(ignoreParentClass?: boolean): void;
  8346. /** @hidden */
  8347. _isSynchronizedViewMatrix(): boolean;
  8348. /** @hidden */
  8349. _computeLocalCameraSpeed(): number;
  8350. /**
  8351. * Defines the target the camera should look at.
  8352. * @param target Defines the new target as a Vector or a mesh
  8353. */
  8354. setTarget(target: Vector3): void;
  8355. /**
  8356. * Return the current target position of the camera. This value is expressed in local space.
  8357. * @returns the target position
  8358. */
  8359. getTarget(): Vector3;
  8360. /** @hidden */
  8361. _decideIfNeedsToMove(): boolean;
  8362. /** @hidden */
  8363. _updatePosition(): void;
  8364. /** @hidden */
  8365. _checkInputs(): void;
  8366. protected _updateCameraRotationMatrix(): void;
  8367. /**
  8368. * 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)
  8369. * @returns the current camera
  8370. */
  8371. private _rotateUpVectorWithCameraRotationMatrix;
  8372. private _cachedRotationZ;
  8373. private _cachedQuaternionRotationZ;
  8374. /** @hidden */
  8375. _getViewMatrix(): Matrix;
  8376. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8377. /**
  8378. * @hidden
  8379. */
  8380. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8381. /**
  8382. * @hidden
  8383. */
  8384. _updateRigCameras(): void;
  8385. private _getRigCamPositionAndTarget;
  8386. /**
  8387. * Gets the current object class name.
  8388. * @return the class name
  8389. */
  8390. getClassName(): string;
  8391. }
  8392. }
  8393. declare module BABYLON {
  8394. /**
  8395. * Gather the list of keyboard event types as constants.
  8396. */
  8397. export class KeyboardEventTypes {
  8398. /**
  8399. * The keydown event is fired when a key becomes active (pressed).
  8400. */
  8401. static readonly KEYDOWN: number;
  8402. /**
  8403. * The keyup event is fired when a key has been released.
  8404. */
  8405. static readonly KEYUP: number;
  8406. }
  8407. /**
  8408. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8409. */
  8410. export class KeyboardInfo {
  8411. /**
  8412. * Defines the type of event (KeyboardEventTypes)
  8413. */
  8414. type: number;
  8415. /**
  8416. * Defines the related dom event
  8417. */
  8418. event: KeyboardEvent;
  8419. /**
  8420. * Instantiates a new keyboard info.
  8421. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8422. * @param type Defines the type of event (KeyboardEventTypes)
  8423. * @param event Defines the related dom event
  8424. */
  8425. constructor(
  8426. /**
  8427. * Defines the type of event (KeyboardEventTypes)
  8428. */
  8429. type: number,
  8430. /**
  8431. * Defines the related dom event
  8432. */
  8433. event: KeyboardEvent);
  8434. }
  8435. /**
  8436. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8437. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8438. */
  8439. export class KeyboardInfoPre extends KeyboardInfo {
  8440. /**
  8441. * Defines the type of event (KeyboardEventTypes)
  8442. */
  8443. type: number;
  8444. /**
  8445. * Defines the related dom event
  8446. */
  8447. event: KeyboardEvent;
  8448. /**
  8449. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8450. */
  8451. skipOnPointerObservable: boolean;
  8452. /**
  8453. * Instantiates a new keyboard pre info.
  8454. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8455. * @param type Defines the type of event (KeyboardEventTypes)
  8456. * @param event Defines the related dom event
  8457. */
  8458. constructor(
  8459. /**
  8460. * Defines the type of event (KeyboardEventTypes)
  8461. */
  8462. type: number,
  8463. /**
  8464. * Defines the related dom event
  8465. */
  8466. event: KeyboardEvent);
  8467. }
  8468. }
  8469. declare module BABYLON {
  8470. /**
  8471. * Manage the keyboard inputs to control the movement of a free camera.
  8472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8473. */
  8474. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8475. /**
  8476. * Defines the camera the input is attached to.
  8477. */
  8478. camera: FreeCamera;
  8479. /**
  8480. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8481. */
  8482. keysUp: number[];
  8483. /**
  8484. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8485. */
  8486. keysDown: number[];
  8487. /**
  8488. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8489. */
  8490. keysLeft: number[];
  8491. /**
  8492. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8493. */
  8494. keysRight: number[];
  8495. private _keys;
  8496. private _onCanvasBlurObserver;
  8497. private _onKeyboardObserver;
  8498. private _engine;
  8499. private _scene;
  8500. /**
  8501. * Attach the input controls to a specific dom element to get the input from.
  8502. * @param element Defines the element the controls should be listened from
  8503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8504. */
  8505. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8506. /**
  8507. * Detach the current controls from the specified dom element.
  8508. * @param element Defines the element to stop listening the inputs from
  8509. */
  8510. detachControl(element: Nullable<HTMLElement>): void;
  8511. /**
  8512. * Update the current camera state depending on the inputs that have been used this frame.
  8513. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8514. */
  8515. checkInputs(): void;
  8516. /**
  8517. * Gets the class name of the current intput.
  8518. * @returns the class name
  8519. */
  8520. getClassName(): string;
  8521. /** @hidden */
  8522. _onLostFocus(): void;
  8523. /**
  8524. * Get the friendly name associated with the input class.
  8525. * @returns the input friendly name
  8526. */
  8527. getSimpleName(): string;
  8528. }
  8529. }
  8530. declare module BABYLON {
  8531. /**
  8532. * Interface describing all the common properties and methods a shadow light needs to implement.
  8533. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8534. * as well as binding the different shadow properties to the effects.
  8535. */
  8536. export interface IShadowLight extends Light {
  8537. /**
  8538. * The light id in the scene (used in scene.findLighById for instance)
  8539. */
  8540. id: string;
  8541. /**
  8542. * The position the shdow will be casted from.
  8543. */
  8544. position: Vector3;
  8545. /**
  8546. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8547. */
  8548. direction: Vector3;
  8549. /**
  8550. * The transformed position. Position of the light in world space taking parenting in account.
  8551. */
  8552. transformedPosition: Vector3;
  8553. /**
  8554. * The transformed direction. Direction of the light in world space taking parenting in account.
  8555. */
  8556. transformedDirection: Vector3;
  8557. /**
  8558. * The friendly name of the light in the scene.
  8559. */
  8560. name: string;
  8561. /**
  8562. * Defines the shadow projection clipping minimum z value.
  8563. */
  8564. shadowMinZ: number;
  8565. /**
  8566. * Defines the shadow projection clipping maximum z value.
  8567. */
  8568. shadowMaxZ: number;
  8569. /**
  8570. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8571. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8572. */
  8573. computeTransformedInformation(): boolean;
  8574. /**
  8575. * Gets the scene the light belongs to.
  8576. * @returns The scene
  8577. */
  8578. getScene(): Scene;
  8579. /**
  8580. * Callback defining a custom Projection Matrix Builder.
  8581. * This can be used to override the default projection matrix computation.
  8582. */
  8583. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8584. /**
  8585. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8586. * @param matrix The materix to updated with the projection information
  8587. * @param viewMatrix The transform matrix of the light
  8588. * @param renderList The list of mesh to render in the map
  8589. * @returns The current light
  8590. */
  8591. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8592. /**
  8593. * Gets the current depth scale used in ESM.
  8594. * @returns The scale
  8595. */
  8596. getDepthScale(): number;
  8597. /**
  8598. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8599. * @returns true if a cube texture needs to be use
  8600. */
  8601. needCube(): boolean;
  8602. /**
  8603. * Detects if the projection matrix requires to be recomputed this frame.
  8604. * @returns true if it requires to be recomputed otherwise, false.
  8605. */
  8606. needProjectionMatrixCompute(): boolean;
  8607. /**
  8608. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8609. */
  8610. forceProjectionMatrixCompute(): void;
  8611. /**
  8612. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8613. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8614. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8615. */
  8616. getShadowDirection(faceIndex?: number): Vector3;
  8617. /**
  8618. * Gets the minZ used for shadow according to both the scene and the light.
  8619. * @param activeCamera The camera we are returning the min for
  8620. * @returns the depth min z
  8621. */
  8622. getDepthMinZ(activeCamera: Camera): number;
  8623. /**
  8624. * Gets the maxZ used for shadow according to both the scene and the light.
  8625. * @param activeCamera The camera we are returning the max for
  8626. * @returns the depth max z
  8627. */
  8628. getDepthMaxZ(activeCamera: Camera): number;
  8629. }
  8630. /**
  8631. * Base implementation IShadowLight
  8632. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8633. */
  8634. export abstract class ShadowLight extends Light implements IShadowLight {
  8635. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8636. protected _position: Vector3;
  8637. protected _setPosition(value: Vector3): void;
  8638. /**
  8639. * Sets the position the shadow will be casted from. Also use as the light position for both
  8640. * point and spot lights.
  8641. */
  8642. /**
  8643. * Sets the position the shadow will be casted from. Also use as the light position for both
  8644. * point and spot lights.
  8645. */
  8646. position: Vector3;
  8647. protected _direction: Vector3;
  8648. protected _setDirection(value: Vector3): void;
  8649. /**
  8650. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8651. * Also use as the light direction on spot and directional lights.
  8652. */
  8653. /**
  8654. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8655. * Also use as the light direction on spot and directional lights.
  8656. */
  8657. direction: Vector3;
  8658. private _shadowMinZ;
  8659. /**
  8660. * Gets the shadow projection clipping minimum z value.
  8661. */
  8662. /**
  8663. * Sets the shadow projection clipping minimum z value.
  8664. */
  8665. shadowMinZ: number;
  8666. private _shadowMaxZ;
  8667. /**
  8668. * Sets the shadow projection clipping maximum z value.
  8669. */
  8670. /**
  8671. * Gets the shadow projection clipping maximum z value.
  8672. */
  8673. shadowMaxZ: number;
  8674. /**
  8675. * Callback defining a custom Projection Matrix Builder.
  8676. * This can be used to override the default projection matrix computation.
  8677. */
  8678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8679. /**
  8680. * The transformed position. Position of the light in world space taking parenting in account.
  8681. */
  8682. transformedPosition: Vector3;
  8683. /**
  8684. * The transformed direction. Direction of the light in world space taking parenting in account.
  8685. */
  8686. transformedDirection: Vector3;
  8687. private _needProjectionMatrixCompute;
  8688. /**
  8689. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8690. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8691. */
  8692. computeTransformedInformation(): boolean;
  8693. /**
  8694. * Return the depth scale used for the shadow map.
  8695. * @returns the depth scale.
  8696. */
  8697. getDepthScale(): number;
  8698. /**
  8699. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8700. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8701. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8702. */
  8703. getShadowDirection(faceIndex?: number): Vector3;
  8704. /**
  8705. * Returns the ShadowLight absolute position in the World.
  8706. * @returns the position vector in world space
  8707. */
  8708. getAbsolutePosition(): Vector3;
  8709. /**
  8710. * Sets the ShadowLight direction toward the passed target.
  8711. * @param target The point to target in local space
  8712. * @returns the updated ShadowLight direction
  8713. */
  8714. setDirectionToTarget(target: Vector3): Vector3;
  8715. /**
  8716. * Returns the light rotation in euler definition.
  8717. * @returns the x y z rotation in local space.
  8718. */
  8719. getRotation(): Vector3;
  8720. /**
  8721. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8722. * @returns true if a cube texture needs to be use
  8723. */
  8724. needCube(): boolean;
  8725. /**
  8726. * Detects if the projection matrix requires to be recomputed this frame.
  8727. * @returns true if it requires to be recomputed otherwise, false.
  8728. */
  8729. needProjectionMatrixCompute(): boolean;
  8730. /**
  8731. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8732. */
  8733. forceProjectionMatrixCompute(): void;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _isSynchronized(): boolean;
  8738. /**
  8739. * Computes the world matrix of the node
  8740. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8741. * @returns the world matrix
  8742. */
  8743. computeWorldMatrix(force?: boolean): Matrix;
  8744. /**
  8745. * Gets the minZ used for shadow according to both the scene and the light.
  8746. * @param activeCamera The camera we are returning the min for
  8747. * @returns the depth min z
  8748. */
  8749. getDepthMinZ(activeCamera: Camera): number;
  8750. /**
  8751. * Gets the maxZ used for shadow according to both the scene and the light.
  8752. * @param activeCamera The camera we are returning the max for
  8753. * @returns the depth max z
  8754. */
  8755. getDepthMaxZ(activeCamera: Camera): number;
  8756. /**
  8757. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8758. * @param matrix The materix to updated with the projection information
  8759. * @param viewMatrix The transform matrix of the light
  8760. * @param renderList The list of mesh to render in the map
  8761. * @returns The current light
  8762. */
  8763. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8764. }
  8765. }
  8766. declare module BABYLON {
  8767. /**
  8768. * "Static Class" containing the most commonly used helper while dealing with material for
  8769. * rendering purpose.
  8770. *
  8771. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8772. *
  8773. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8774. */
  8775. export class MaterialHelper {
  8776. /**
  8777. * Bind the current view position to an effect.
  8778. * @param effect The effect to be bound
  8779. * @param scene The scene the eyes position is used from
  8780. */
  8781. static BindEyePosition(effect: Effect, scene: Scene): void;
  8782. /**
  8783. * Helps preparing the defines values about the UVs in used in the effect.
  8784. * UVs are shared as much as we can accross channels in the shaders.
  8785. * @param texture The texture we are preparing the UVs for
  8786. * @param defines The defines to update
  8787. * @param key The channel key "diffuse", "specular"... used in the shader
  8788. */
  8789. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8790. /**
  8791. * Binds a texture matrix value to its corrsponding uniform
  8792. * @param texture The texture to bind the matrix for
  8793. * @param uniformBuffer The uniform buffer receivin the data
  8794. * @param key The channel key "diffuse", "specular"... used in the shader
  8795. */
  8796. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8797. /**
  8798. * Gets the current status of the fog (should it be enabled?)
  8799. * @param mesh defines the mesh to evaluate for fog support
  8800. * @param scene defines the hosting scene
  8801. * @returns true if fog must be enabled
  8802. */
  8803. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8804. /**
  8805. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8806. * @param mesh defines the current mesh
  8807. * @param scene defines the current scene
  8808. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8809. * @param pointsCloud defines if point cloud rendering has to be turned on
  8810. * @param fogEnabled defines if fog has to be turned on
  8811. * @param alphaTest defines if alpha testing has to be turned on
  8812. * @param defines defines the current list of defines
  8813. */
  8814. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8815. /**
  8816. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8817. * @param scene defines the current scene
  8818. * @param engine defines the current engine
  8819. * @param defines specifies the list of active defines
  8820. * @param useInstances defines if instances have to be turned on
  8821. * @param useClipPlane defines if clip plane have to be turned on
  8822. */
  8823. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8824. /**
  8825. * Prepares the defines for bones
  8826. * @param mesh The mesh containing the geometry data we will draw
  8827. * @param defines The defines to update
  8828. */
  8829. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8830. /**
  8831. * Prepares the defines for morph targets
  8832. * @param mesh The mesh containing the geometry data we will draw
  8833. * @param defines The defines to update
  8834. */
  8835. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8836. /**
  8837. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8838. * @param mesh The mesh containing the geometry data we will draw
  8839. * @param defines The defines to update
  8840. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8841. * @param useBones Precise whether bones should be used or not (override mesh info)
  8842. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8843. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8844. * @returns false if defines are considered not dirty and have not been checked
  8845. */
  8846. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8847. /**
  8848. * Prepares the defines related to multiview
  8849. * @param scene The scene we are intending to draw
  8850. * @param defines The defines to update
  8851. */
  8852. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8853. /**
  8854. * Prepares the defines related to the light information passed in parameter
  8855. * @param scene The scene we are intending to draw
  8856. * @param mesh The mesh the effect is compiling for
  8857. * @param light The light the effect is compiling for
  8858. * @param lightIndex The index of the light
  8859. * @param defines The defines to update
  8860. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8861. * @param state Defines the current state regarding what is needed (normals, etc...)
  8862. */
  8863. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8864. needNormals: boolean;
  8865. needRebuild: boolean;
  8866. shadowEnabled: boolean;
  8867. specularEnabled: boolean;
  8868. lightmapMode: boolean;
  8869. }): void;
  8870. /**
  8871. * Prepares the defines related to the light information passed in parameter
  8872. * @param scene The scene we are intending to draw
  8873. * @param mesh The mesh the effect is compiling for
  8874. * @param defines The defines to update
  8875. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8876. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8877. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8878. * @returns true if normals will be required for the rest of the effect
  8879. */
  8880. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8881. /**
  8882. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8883. * @param lightIndex defines the light index
  8884. * @param uniformsList The uniform list
  8885. * @param samplersList The sampler list
  8886. * @param projectedLightTexture defines if projected texture must be used
  8887. * @param uniformBuffersList defines an optional list of uniform buffers
  8888. */
  8889. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8890. /**
  8891. * Prepares the uniforms and samplers list to be used in the effect
  8892. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8893. * @param samplersList The sampler list
  8894. * @param defines The defines helping in the list generation
  8895. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8896. */
  8897. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8898. /**
  8899. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8900. * @param defines The defines to update while falling back
  8901. * @param fallbacks The authorized effect fallbacks
  8902. * @param maxSimultaneousLights The maximum number of lights allowed
  8903. * @param rank the current rank of the Effect
  8904. * @returns The newly affected rank
  8905. */
  8906. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8907. private static _TmpMorphInfluencers;
  8908. /**
  8909. * Prepares the list of attributes required for morph targets according to the effect defines.
  8910. * @param attribs The current list of supported attribs
  8911. * @param mesh The mesh to prepare the morph targets attributes for
  8912. * @param influencers The number of influencers
  8913. */
  8914. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8915. /**
  8916. * Prepares the list of attributes required for morph targets according to the effect defines.
  8917. * @param attribs The current list of supported attribs
  8918. * @param mesh The mesh to prepare the morph targets attributes for
  8919. * @param defines The current Defines of the effect
  8920. */
  8921. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8922. /**
  8923. * Prepares the list of attributes required for bones according to the effect defines.
  8924. * @param attribs The current list of supported attribs
  8925. * @param mesh The mesh to prepare the bones attributes for
  8926. * @param defines The current Defines of the effect
  8927. * @param fallbacks The current efffect fallback strategy
  8928. */
  8929. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8930. /**
  8931. * Check and prepare the list of attributes required for instances according to the effect defines.
  8932. * @param attribs The current list of supported attribs
  8933. * @param defines The current MaterialDefines of the effect
  8934. */
  8935. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8936. /**
  8937. * Add the list of attributes required for instances to the attribs array.
  8938. * @param attribs The current list of supported attribs
  8939. */
  8940. static PushAttributesForInstances(attribs: string[]): void;
  8941. /**
  8942. * Binds the light shadow information to the effect for the given mesh.
  8943. * @param light The light containing the generator
  8944. * @param scene The scene the lights belongs to
  8945. * @param mesh The mesh we are binding the information to render
  8946. * @param lightIndex The light index in the effect used to render the mesh
  8947. * @param effect The effect we are binding the data to
  8948. */
  8949. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8950. /**
  8951. * Binds the light information to the effect.
  8952. * @param light The light containing the generator
  8953. * @param effect The effect we are binding the data to
  8954. * @param lightIndex The light index in the effect used to render
  8955. */
  8956. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8957. /**
  8958. * Binds the lights information from the scene to the effect for the given mesh.
  8959. * @param light Light to bind
  8960. * @param lightIndex Light index
  8961. * @param scene The scene where the light belongs to
  8962. * @param mesh The mesh we are binding the information to render
  8963. * @param effect The effect we are binding the data to
  8964. * @param useSpecular Defines if specular is supported
  8965. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8966. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8967. */
  8968. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8969. /**
  8970. * Binds the lights information from the scene to the effect for the given mesh.
  8971. * @param scene The scene the lights belongs to
  8972. * @param mesh The mesh we are binding the information to render
  8973. * @param effect The effect we are binding the data to
  8974. * @param defines The generated defines for the effect
  8975. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8976. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8977. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8978. */
  8979. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8980. private static _tempFogColor;
  8981. /**
  8982. * Binds the fog information from the scene to the effect for the given mesh.
  8983. * @param scene The scene the lights belongs to
  8984. * @param mesh The mesh we are binding the information to render
  8985. * @param effect The effect we are binding the data to
  8986. * @param linearSpace Defines if the fog effect is applied in linear space
  8987. */
  8988. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8989. /**
  8990. * Binds the bones information from the mesh to the effect.
  8991. * @param mesh The mesh we are binding the information to render
  8992. * @param effect The effect we are binding the data to
  8993. */
  8994. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8995. /**
  8996. * Binds the morph targets information from the mesh to the effect.
  8997. * @param abstractMesh The mesh we are binding the information to render
  8998. * @param effect The effect we are binding the data to
  8999. */
  9000. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9001. /**
  9002. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9003. * @param defines The generated defines used in the effect
  9004. * @param effect The effect we are binding the data to
  9005. * @param scene The scene we are willing to render with logarithmic scale for
  9006. */
  9007. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9008. /**
  9009. * Binds the clip plane information from the scene to the effect.
  9010. * @param scene The scene the clip plane information are extracted from
  9011. * @param effect The effect we are binding the data to
  9012. */
  9013. static BindClipPlane(effect: Effect, scene: Scene): void;
  9014. }
  9015. }
  9016. declare module BABYLON {
  9017. /** @hidden */
  9018. export var packingFunctions: {
  9019. name: string;
  9020. shader: string;
  9021. };
  9022. }
  9023. declare module BABYLON {
  9024. /** @hidden */
  9025. export var shadowMapPixelShader: {
  9026. name: string;
  9027. shader: string;
  9028. };
  9029. }
  9030. declare module BABYLON {
  9031. /** @hidden */
  9032. export var bonesDeclaration: {
  9033. name: string;
  9034. shader: string;
  9035. };
  9036. }
  9037. declare module BABYLON {
  9038. /** @hidden */
  9039. export var morphTargetsVertexGlobalDeclaration: {
  9040. name: string;
  9041. shader: string;
  9042. };
  9043. }
  9044. declare module BABYLON {
  9045. /** @hidden */
  9046. export var morphTargetsVertexDeclaration: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module BABYLON {
  9052. /** @hidden */
  9053. export var instancesDeclaration: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module BABYLON {
  9059. /** @hidden */
  9060. export var helperFunctions: {
  9061. name: string;
  9062. shader: string;
  9063. };
  9064. }
  9065. declare module BABYLON {
  9066. /** @hidden */
  9067. export var morphTargetsVertex: {
  9068. name: string;
  9069. shader: string;
  9070. };
  9071. }
  9072. declare module BABYLON {
  9073. /** @hidden */
  9074. export var instancesVertex: {
  9075. name: string;
  9076. shader: string;
  9077. };
  9078. }
  9079. declare module BABYLON {
  9080. /** @hidden */
  9081. export var bonesVertex: {
  9082. name: string;
  9083. shader: string;
  9084. };
  9085. }
  9086. declare module BABYLON {
  9087. /** @hidden */
  9088. export var shadowMapVertexShader: {
  9089. name: string;
  9090. shader: string;
  9091. };
  9092. }
  9093. declare module BABYLON {
  9094. /** @hidden */
  9095. export var depthBoxBlurPixelShader: {
  9096. name: string;
  9097. shader: string;
  9098. };
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9103. */
  9104. export interface ICustomShaderOptions {
  9105. /**
  9106. * Gets or sets the custom shader name to use
  9107. */
  9108. shaderName: string;
  9109. /**
  9110. * The list of attribute names used in the shader
  9111. */
  9112. attributes?: string[];
  9113. /**
  9114. * The list of unifrom names used in the shader
  9115. */
  9116. uniforms?: string[];
  9117. /**
  9118. * The list of sampler names used in the shader
  9119. */
  9120. samplers?: string[];
  9121. /**
  9122. * The list of defines used in the shader
  9123. */
  9124. defines?: string[];
  9125. }
  9126. /**
  9127. * Interface to implement to create a shadow generator compatible with BJS.
  9128. */
  9129. export interface IShadowGenerator {
  9130. /**
  9131. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9132. * @returns The render target texture if present otherwise, null
  9133. */
  9134. getShadowMap(): Nullable<RenderTargetTexture>;
  9135. /**
  9136. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9137. * @returns The render target texture if the shadow map is present otherwise, null
  9138. */
  9139. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9140. /**
  9141. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9142. * @param subMesh The submesh we want to render in the shadow map
  9143. * @param useInstances Defines wether will draw in the map using instances
  9144. * @returns true if ready otherwise, false
  9145. */
  9146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9147. /**
  9148. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9149. * @param defines Defines of the material we want to update
  9150. * @param lightIndex Index of the light in the enabled light list of the material
  9151. */
  9152. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9153. /**
  9154. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9155. * defined in the generator but impacting the effect).
  9156. * It implies the unifroms available on the materials are the standard BJS ones.
  9157. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9158. * @param effect The effect we are binfing the information for
  9159. */
  9160. bindShadowLight(lightIndex: string, effect: Effect): void;
  9161. /**
  9162. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9163. * (eq to shadow prjection matrix * light transform matrix)
  9164. * @returns The transform matrix used to create the shadow map
  9165. */
  9166. getTransformMatrix(): Matrix;
  9167. /**
  9168. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9169. * Cube and 2D textures for instance.
  9170. */
  9171. recreateShadowMap(): void;
  9172. /**
  9173. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9174. * @param onCompiled Callback triggered at the and of the effects compilation
  9175. * @param options Sets of optional options forcing the compilation with different modes
  9176. */
  9177. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9178. useInstances: boolean;
  9179. }>): void;
  9180. /**
  9181. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9182. * @param options Sets of optional options forcing the compilation with different modes
  9183. * @returns A promise that resolves when the compilation completes
  9184. */
  9185. forceCompilationAsync(options?: Partial<{
  9186. useInstances: boolean;
  9187. }>): Promise<void>;
  9188. /**
  9189. * Serializes the shadow generator setup to a json object.
  9190. * @returns The serialized JSON object
  9191. */
  9192. serialize(): any;
  9193. /**
  9194. * Disposes the Shadow map and related Textures and effects.
  9195. */
  9196. dispose(): void;
  9197. }
  9198. /**
  9199. * Default implementation IShadowGenerator.
  9200. * This is the main object responsible of generating shadows in the framework.
  9201. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9202. */
  9203. export class ShadowGenerator implements IShadowGenerator {
  9204. /**
  9205. * Shadow generator mode None: no filtering applied.
  9206. */
  9207. static readonly FILTER_NONE: number;
  9208. /**
  9209. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9210. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9211. */
  9212. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9213. /**
  9214. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9215. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9216. */
  9217. static readonly FILTER_POISSONSAMPLING: number;
  9218. /**
  9219. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9220. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9221. */
  9222. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9223. /**
  9224. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9225. * edge artifacts on steep falloff.
  9226. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9227. */
  9228. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9229. /**
  9230. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9231. * edge artifacts on steep falloff.
  9232. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9233. */
  9234. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9235. /**
  9236. * Shadow generator mode PCF: Percentage Closer Filtering
  9237. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9238. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9239. */
  9240. static readonly FILTER_PCF: number;
  9241. /**
  9242. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9243. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9244. * Contact Hardening
  9245. */
  9246. static readonly FILTER_PCSS: number;
  9247. /**
  9248. * Reserved for PCF and PCSS
  9249. * Highest Quality.
  9250. *
  9251. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9252. *
  9253. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9254. */
  9255. static readonly QUALITY_HIGH: number;
  9256. /**
  9257. * Reserved for PCF and PCSS
  9258. * Good tradeoff for quality/perf cross devices
  9259. *
  9260. * Execute PCF on a 3*3 kernel.
  9261. *
  9262. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9263. */
  9264. static readonly QUALITY_MEDIUM: number;
  9265. /**
  9266. * Reserved for PCF and PCSS
  9267. * The lowest quality but the fastest.
  9268. *
  9269. * Execute PCF on a 1*1 kernel.
  9270. *
  9271. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9272. */
  9273. static readonly QUALITY_LOW: number;
  9274. /** Gets or sets the custom shader name to use */
  9275. customShaderOptions: ICustomShaderOptions;
  9276. /**
  9277. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9278. */
  9279. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9280. /**
  9281. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9282. */
  9283. onAfterShadowMapRenderObservable: Observable<Effect>;
  9284. /**
  9285. * Observable triggered before a mesh is rendered in the shadow map.
  9286. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9287. */
  9288. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9289. /**
  9290. * Observable triggered after a mesh is rendered in the shadow map.
  9291. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9292. */
  9293. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9294. private _bias;
  9295. /**
  9296. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9297. */
  9298. /**
  9299. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9300. */
  9301. bias: number;
  9302. private _normalBias;
  9303. /**
  9304. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9305. */
  9306. /**
  9307. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9308. */
  9309. normalBias: number;
  9310. private _blurBoxOffset;
  9311. /**
  9312. * Gets the blur box offset: offset applied during the blur pass.
  9313. * Only useful if useKernelBlur = false
  9314. */
  9315. /**
  9316. * Sets the blur box offset: offset applied during the blur pass.
  9317. * Only useful if useKernelBlur = false
  9318. */
  9319. blurBoxOffset: number;
  9320. private _blurScale;
  9321. /**
  9322. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9323. * 2 means half of the size.
  9324. */
  9325. /**
  9326. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9327. * 2 means half of the size.
  9328. */
  9329. blurScale: number;
  9330. private _blurKernel;
  9331. /**
  9332. * Gets the blur kernel: kernel size of the blur pass.
  9333. * Only useful if useKernelBlur = true
  9334. */
  9335. /**
  9336. * Sets the blur kernel: kernel size of the blur pass.
  9337. * Only useful if useKernelBlur = true
  9338. */
  9339. blurKernel: number;
  9340. private _useKernelBlur;
  9341. /**
  9342. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9343. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9344. */
  9345. /**
  9346. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9347. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9348. */
  9349. useKernelBlur: boolean;
  9350. private _depthScale;
  9351. /**
  9352. * Gets the depth scale used in ESM mode.
  9353. */
  9354. /**
  9355. * Sets the depth scale used in ESM mode.
  9356. * This can override the scale stored on the light.
  9357. */
  9358. depthScale: number;
  9359. private _filter;
  9360. /**
  9361. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9362. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9363. */
  9364. /**
  9365. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9366. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9367. */
  9368. filter: number;
  9369. /**
  9370. * Gets if the current filter is set to Poisson Sampling.
  9371. */
  9372. /**
  9373. * Sets the current filter to Poisson Sampling.
  9374. */
  9375. usePoissonSampling: boolean;
  9376. /**
  9377. * Gets if the current filter is set to ESM.
  9378. */
  9379. /**
  9380. * Sets the current filter is to ESM.
  9381. */
  9382. useExponentialShadowMap: boolean;
  9383. /**
  9384. * Gets if the current filter is set to filtered ESM.
  9385. */
  9386. /**
  9387. * Gets if the current filter is set to filtered ESM.
  9388. */
  9389. useBlurExponentialShadowMap: boolean;
  9390. /**
  9391. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9392. * exponential to prevent steep falloff artifacts).
  9393. */
  9394. /**
  9395. * Sets the current filter to "close ESM" (using the inverse of the
  9396. * exponential to prevent steep falloff artifacts).
  9397. */
  9398. useCloseExponentialShadowMap: boolean;
  9399. /**
  9400. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9401. * exponential to prevent steep falloff artifacts).
  9402. */
  9403. /**
  9404. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9405. * exponential to prevent steep falloff artifacts).
  9406. */
  9407. useBlurCloseExponentialShadowMap: boolean;
  9408. /**
  9409. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9410. */
  9411. /**
  9412. * Sets the current filter to "PCF" (percentage closer filtering).
  9413. */
  9414. usePercentageCloserFiltering: boolean;
  9415. private _filteringQuality;
  9416. /**
  9417. * Gets the PCF or PCSS Quality.
  9418. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9419. */
  9420. /**
  9421. * Sets the PCF or PCSS Quality.
  9422. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9423. */
  9424. filteringQuality: number;
  9425. /**
  9426. * Gets if the current filter is set to "PCSS" (contact hardening).
  9427. */
  9428. /**
  9429. * Sets the current filter to "PCSS" (contact hardening).
  9430. */
  9431. useContactHardeningShadow: boolean;
  9432. private _contactHardeningLightSizeUVRatio;
  9433. /**
  9434. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9435. * Using a ratio helps keeping shape stability independently of the map size.
  9436. *
  9437. * It does not account for the light projection as it was having too much
  9438. * instability during the light setup or during light position changes.
  9439. *
  9440. * Only valid if useContactHardeningShadow is true.
  9441. */
  9442. /**
  9443. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9444. * Using a ratio helps keeping shape stability independently of the map size.
  9445. *
  9446. * It does not account for the light projection as it was having too much
  9447. * instability during the light setup or during light position changes.
  9448. *
  9449. * Only valid if useContactHardeningShadow is true.
  9450. */
  9451. contactHardeningLightSizeUVRatio: number;
  9452. private _darkness;
  9453. /** Gets or sets the actual darkness of a shadow */
  9454. darkness: number;
  9455. /**
  9456. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9457. * 0 means strongest and 1 would means no shadow.
  9458. * @returns the darkness.
  9459. */
  9460. getDarkness(): number;
  9461. /**
  9462. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9463. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9464. * @returns the shadow generator allowing fluent coding.
  9465. */
  9466. setDarkness(darkness: number): ShadowGenerator;
  9467. private _transparencyShadow;
  9468. /** Gets or sets the ability to have transparent shadow */
  9469. transparencyShadow: boolean;
  9470. /**
  9471. * Sets the ability to have transparent shadow (boolean).
  9472. * @param transparent True if transparent else False
  9473. * @returns the shadow generator allowing fluent coding
  9474. */
  9475. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9476. private _shadowMap;
  9477. private _shadowMap2;
  9478. /**
  9479. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9480. * @returns The render target texture if present otherwise, null
  9481. */
  9482. getShadowMap(): Nullable<RenderTargetTexture>;
  9483. /**
  9484. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9485. * @returns The render target texture if the shadow map is present otherwise, null
  9486. */
  9487. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9488. /**
  9489. * Gets the class name of that object
  9490. * @returns "ShadowGenerator"
  9491. */
  9492. getClassName(): string;
  9493. /**
  9494. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9495. * @param mesh Mesh to add
  9496. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9497. * @returns the Shadow Generator itself
  9498. */
  9499. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9500. /**
  9501. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9502. * @param mesh Mesh to remove
  9503. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9504. * @returns the Shadow Generator itself
  9505. */
  9506. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9507. /**
  9508. * Controls the extent to which the shadows fade out at the edge of the frustum
  9509. * Used only by directionals and spots
  9510. */
  9511. frustumEdgeFalloff: number;
  9512. private _light;
  9513. /**
  9514. * Returns the associated light object.
  9515. * @returns the light generating the shadow
  9516. */
  9517. getLight(): IShadowLight;
  9518. /**
  9519. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9520. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9521. * It might on the other hand introduce peter panning.
  9522. */
  9523. forceBackFacesOnly: boolean;
  9524. private _scene;
  9525. private _lightDirection;
  9526. private _effect;
  9527. private _viewMatrix;
  9528. private _projectionMatrix;
  9529. private _transformMatrix;
  9530. private _cachedPosition;
  9531. private _cachedDirection;
  9532. private _cachedDefines;
  9533. private _currentRenderID;
  9534. private _boxBlurPostprocess;
  9535. private _kernelBlurXPostprocess;
  9536. private _kernelBlurYPostprocess;
  9537. private _blurPostProcesses;
  9538. private _mapSize;
  9539. private _currentFaceIndex;
  9540. private _currentFaceIndexCache;
  9541. private _textureType;
  9542. private _defaultTextureMatrix;
  9543. /** @hidden */
  9544. static _SceneComponentInitialization: (scene: Scene) => void;
  9545. /**
  9546. * Creates a ShadowGenerator object.
  9547. * A ShadowGenerator is the required tool to use the shadows.
  9548. * Each light casting shadows needs to use its own ShadowGenerator.
  9549. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9550. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9551. * @param light The light object generating the shadows.
  9552. * @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.
  9553. */
  9554. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9555. private _initializeGenerator;
  9556. private _initializeShadowMap;
  9557. private _initializeBlurRTTAndPostProcesses;
  9558. private _renderForShadowMap;
  9559. private _renderSubMeshForShadowMap;
  9560. private _applyFilterValues;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param onCompiled Callback triggered at the and of the effects compilation
  9564. * @param options Sets of optional options forcing the compilation with different modes
  9565. */
  9566. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): void;
  9569. /**
  9570. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9571. * @param options Sets of optional options forcing the compilation with different modes
  9572. * @returns A promise that resolves when the compilation completes
  9573. */
  9574. forceCompilationAsync(options?: Partial<{
  9575. useInstances: boolean;
  9576. }>): Promise<void>;
  9577. /**
  9578. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9579. * @param subMesh The submesh we want to render in the shadow map
  9580. * @param useInstances Defines wether will draw in the map using instances
  9581. * @returns true if ready otherwise, false
  9582. */
  9583. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9584. /**
  9585. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9586. * @param defines Defines of the material we want to update
  9587. * @param lightIndex Index of the light in the enabled light list of the material
  9588. */
  9589. prepareDefines(defines: any, lightIndex: number): void;
  9590. /**
  9591. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9592. * defined in the generator but impacting the effect).
  9593. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9594. * @param effect The effect we are binfing the information for
  9595. */
  9596. bindShadowLight(lightIndex: string, effect: Effect): void;
  9597. /**
  9598. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9599. * (eq to shadow prjection matrix * light transform matrix)
  9600. * @returns The transform matrix used to create the shadow map
  9601. */
  9602. getTransformMatrix(): Matrix;
  9603. /**
  9604. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9605. * Cube and 2D textures for instance.
  9606. */
  9607. recreateShadowMap(): void;
  9608. private _disposeBlurPostProcesses;
  9609. private _disposeRTTandPostProcesses;
  9610. /**
  9611. * Disposes the ShadowGenerator.
  9612. * Returns nothing.
  9613. */
  9614. dispose(): void;
  9615. /**
  9616. * Serializes the shadow generator setup to a json object.
  9617. * @returns The serialized JSON object
  9618. */
  9619. serialize(): any;
  9620. /**
  9621. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9622. * @param parsedShadowGenerator The JSON object to parse
  9623. * @param scene The scene to create the shadow map for
  9624. * @returns The parsed shadow generator
  9625. */
  9626. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9627. }
  9628. }
  9629. declare module BABYLON {
  9630. /**
  9631. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9632. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9633. * 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.
  9634. */
  9635. export abstract class Light extends Node {
  9636. /**
  9637. * Falloff Default: light is falling off following the material specification:
  9638. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9639. */
  9640. static readonly FALLOFF_DEFAULT: number;
  9641. /**
  9642. * Falloff Physical: light is falling off following the inverse squared distance law.
  9643. */
  9644. static readonly FALLOFF_PHYSICAL: number;
  9645. /**
  9646. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9647. * to enhance interoperability with other engines.
  9648. */
  9649. static readonly FALLOFF_GLTF: number;
  9650. /**
  9651. * Falloff Standard: light is falling off like in the standard material
  9652. * to enhance interoperability with other materials.
  9653. */
  9654. static readonly FALLOFF_STANDARD: number;
  9655. /**
  9656. * If every light affecting the material is in this lightmapMode,
  9657. * material.lightmapTexture adds or multiplies
  9658. * (depends on material.useLightmapAsShadowmap)
  9659. * after every other light calculations.
  9660. */
  9661. static readonly LIGHTMAP_DEFAULT: number;
  9662. /**
  9663. * material.lightmapTexture as only diffuse lighting from this light
  9664. * adds only specular lighting from this light
  9665. * adds dynamic shadows
  9666. */
  9667. static readonly LIGHTMAP_SPECULAR: number;
  9668. /**
  9669. * material.lightmapTexture as only lighting
  9670. * no light calculation from this light
  9671. * only adds dynamic shadows from this light
  9672. */
  9673. static readonly LIGHTMAP_SHADOWSONLY: number;
  9674. /**
  9675. * Each light type uses the default quantity according to its type:
  9676. * point/spot lights use luminous intensity
  9677. * directional lights use illuminance
  9678. */
  9679. static readonly INTENSITYMODE_AUTOMATIC: number;
  9680. /**
  9681. * lumen (lm)
  9682. */
  9683. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9684. /**
  9685. * candela (lm/sr)
  9686. */
  9687. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9688. /**
  9689. * lux (lm/m^2)
  9690. */
  9691. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9692. /**
  9693. * nit (cd/m^2)
  9694. */
  9695. static readonly INTENSITYMODE_LUMINANCE: number;
  9696. /**
  9697. * Light type const id of the point light.
  9698. */
  9699. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9700. /**
  9701. * Light type const id of the directional light.
  9702. */
  9703. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9704. /**
  9705. * Light type const id of the spot light.
  9706. */
  9707. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9708. /**
  9709. * Light type const id of the hemispheric light.
  9710. */
  9711. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9712. /**
  9713. * Diffuse gives the basic color to an object.
  9714. */
  9715. diffuse: Color3;
  9716. /**
  9717. * Specular produces a highlight color on an object.
  9718. * Note: This is note affecting PBR materials.
  9719. */
  9720. specular: Color3;
  9721. /**
  9722. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9723. * falling off base on range or angle.
  9724. * This can be set to any values in Light.FALLOFF_x.
  9725. *
  9726. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9727. * other types of materials.
  9728. */
  9729. falloffType: number;
  9730. /**
  9731. * Strength of the light.
  9732. * Note: By default it is define in the framework own unit.
  9733. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9734. */
  9735. intensity: number;
  9736. private _range;
  9737. protected _inverseSquaredRange: number;
  9738. /**
  9739. * Defines how far from the source the light is impacting in scene units.
  9740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9741. */
  9742. /**
  9743. * Defines how far from the source the light is impacting in scene units.
  9744. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9745. */
  9746. range: number;
  9747. /**
  9748. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9749. * of light.
  9750. */
  9751. private _photometricScale;
  9752. private _intensityMode;
  9753. /**
  9754. * Gets the photometric scale used to interpret the intensity.
  9755. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9756. */
  9757. /**
  9758. * Sets the photometric scale used to interpret the intensity.
  9759. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9760. */
  9761. intensityMode: number;
  9762. private _radius;
  9763. /**
  9764. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9765. */
  9766. /**
  9767. * sets the light radius used by PBR Materials to simulate soft area lights.
  9768. */
  9769. radius: number;
  9770. private _renderPriority;
  9771. /**
  9772. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9773. * exceeding the number allowed of the materials.
  9774. */
  9775. renderPriority: number;
  9776. private _shadowEnabled;
  9777. /**
  9778. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9779. * the current shadow generator.
  9780. */
  9781. /**
  9782. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9783. * the current shadow generator.
  9784. */
  9785. shadowEnabled: boolean;
  9786. private _includedOnlyMeshes;
  9787. /**
  9788. * Gets the only meshes impacted by this light.
  9789. */
  9790. /**
  9791. * Sets the only meshes impacted by this light.
  9792. */
  9793. includedOnlyMeshes: AbstractMesh[];
  9794. private _excludedMeshes;
  9795. /**
  9796. * Gets the meshes not impacted by this light.
  9797. */
  9798. /**
  9799. * Sets the meshes not impacted by this light.
  9800. */
  9801. excludedMeshes: AbstractMesh[];
  9802. private _excludeWithLayerMask;
  9803. /**
  9804. * Gets the layer id use to find what meshes are not impacted by the light.
  9805. * Inactive if 0
  9806. */
  9807. /**
  9808. * Sets the layer id use to find what meshes are not impacted by the light.
  9809. * Inactive if 0
  9810. */
  9811. excludeWithLayerMask: number;
  9812. private _includeOnlyWithLayerMask;
  9813. /**
  9814. * Gets the layer id use to find what meshes are impacted by the light.
  9815. * Inactive if 0
  9816. */
  9817. /**
  9818. * Sets the layer id use to find what meshes are impacted by the light.
  9819. * Inactive if 0
  9820. */
  9821. includeOnlyWithLayerMask: number;
  9822. private _lightmapMode;
  9823. /**
  9824. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9825. */
  9826. /**
  9827. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9828. */
  9829. lightmapMode: number;
  9830. /**
  9831. * Shadow generator associted to the light.
  9832. * @hidden Internal use only.
  9833. */
  9834. _shadowGenerator: Nullable<IShadowGenerator>;
  9835. /**
  9836. * @hidden Internal use only.
  9837. */
  9838. _excludedMeshesIds: string[];
  9839. /**
  9840. * @hidden Internal use only.
  9841. */
  9842. _includedOnlyMeshesIds: string[];
  9843. /**
  9844. * The current light unifom buffer.
  9845. * @hidden Internal use only.
  9846. */
  9847. _uniformBuffer: UniformBuffer;
  9848. /**
  9849. * Creates a Light object in the scene.
  9850. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9851. * @param name The firendly name of the light
  9852. * @param scene The scene the light belongs too
  9853. */
  9854. constructor(name: string, scene: Scene);
  9855. protected abstract _buildUniformLayout(): void;
  9856. /**
  9857. * Sets the passed Effect "effect" with the Light information.
  9858. * @param effect The effect to update
  9859. * @param lightIndex The index of the light in the effect to update
  9860. * @returns The light
  9861. */
  9862. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9863. /**
  9864. * Sets the passed Effect "effect" with the Light information.
  9865. * @param effect The effect to update
  9866. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9867. * @returns The light
  9868. */
  9869. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9870. /**
  9871. * Returns the string "Light".
  9872. * @returns the class name
  9873. */
  9874. getClassName(): string;
  9875. /** @hidden */
  9876. readonly _isLight: boolean;
  9877. /**
  9878. * Converts the light information to a readable string for debug purpose.
  9879. * @param fullDetails Supports for multiple levels of logging within scene loading
  9880. * @returns the human readable light info
  9881. */
  9882. toString(fullDetails?: boolean): string;
  9883. /** @hidden */
  9884. protected _syncParentEnabledState(): void;
  9885. /**
  9886. * Set the enabled state of this node.
  9887. * @param value - the new enabled state
  9888. */
  9889. setEnabled(value: boolean): void;
  9890. /**
  9891. * Returns the Light associated shadow generator if any.
  9892. * @return the associated shadow generator.
  9893. */
  9894. getShadowGenerator(): Nullable<IShadowGenerator>;
  9895. /**
  9896. * Returns a Vector3, the absolute light position in the World.
  9897. * @returns the world space position of the light
  9898. */
  9899. getAbsolutePosition(): Vector3;
  9900. /**
  9901. * Specifies if the light will affect the passed mesh.
  9902. * @param mesh The mesh to test against the light
  9903. * @return true the mesh is affected otherwise, false.
  9904. */
  9905. canAffectMesh(mesh: AbstractMesh): boolean;
  9906. /**
  9907. * Sort function to order lights for rendering.
  9908. * @param a First Light object to compare to second.
  9909. * @param b Second Light object to compare first.
  9910. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9911. */
  9912. static CompareLightsPriority(a: Light, b: Light): number;
  9913. /**
  9914. * Releases resources associated with this node.
  9915. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9916. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9917. */
  9918. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9919. /**
  9920. * Returns the light type ID (integer).
  9921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9922. */
  9923. getTypeID(): number;
  9924. /**
  9925. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9926. * @returns the scaled intensity in intensity mode unit
  9927. */
  9928. getScaledIntensity(): number;
  9929. /**
  9930. * Returns a new Light object, named "name", from the current one.
  9931. * @param name The name of the cloned light
  9932. * @returns the new created light
  9933. */
  9934. clone(name: string): Nullable<Light>;
  9935. /**
  9936. * Serializes the current light into a Serialization object.
  9937. * @returns the serialized object.
  9938. */
  9939. serialize(): any;
  9940. /**
  9941. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9942. * This new light is named "name" and added to the passed scene.
  9943. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9944. * @param name The friendly name of the light
  9945. * @param scene The scene the new light will belong to
  9946. * @returns the constructor function
  9947. */
  9948. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9949. /**
  9950. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9951. * @param parsedLight The JSON representation of the light
  9952. * @param scene The scene to create the parsed light in
  9953. * @returns the created light after parsing
  9954. */
  9955. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9956. private _hookArrayForExcluded;
  9957. private _hookArrayForIncludedOnly;
  9958. private _resyncMeshes;
  9959. /**
  9960. * Forces the meshes to update their light related information in their rendering used effects
  9961. * @hidden Internal Use Only
  9962. */
  9963. _markMeshesAsLightDirty(): void;
  9964. /**
  9965. * Recomputes the cached photometric scale if needed.
  9966. */
  9967. private _computePhotometricScale;
  9968. /**
  9969. * Returns the Photometric Scale according to the light type and intensity mode.
  9970. */
  9971. private _getPhotometricScale;
  9972. /**
  9973. * Reorder the light in the scene according to their defined priority.
  9974. * @hidden Internal Use Only
  9975. */
  9976. _reorderLightsInScene(): void;
  9977. /**
  9978. * Prepares the list of defines specific to the light type.
  9979. * @param defines the list of defines
  9980. * @param lightIndex defines the index of the light for the effect
  9981. */
  9982. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9983. }
  9984. }
  9985. declare module BABYLON {
  9986. /**
  9987. * Interface used to define Action
  9988. */
  9989. export interface IAction {
  9990. /**
  9991. * Trigger for the action
  9992. */
  9993. trigger: number;
  9994. /** Options of the trigger */
  9995. triggerOptions: any;
  9996. /**
  9997. * Gets the trigger parameters
  9998. * @returns the trigger parameters
  9999. */
  10000. getTriggerParameter(): any;
  10001. /**
  10002. * Internal only - executes current action event
  10003. * @hidden
  10004. */
  10005. _executeCurrent(evt?: ActionEvent): void;
  10006. /**
  10007. * Serialize placeholder for child classes
  10008. * @param parent of child
  10009. * @returns the serialized object
  10010. */
  10011. serialize(parent: any): any;
  10012. /**
  10013. * Internal only
  10014. * @hidden
  10015. */
  10016. _prepare(): void;
  10017. /**
  10018. * Internal only - manager for action
  10019. * @hidden
  10020. */
  10021. _actionManager: AbstractActionManager;
  10022. /**
  10023. * Adds action to chain of actions, may be a DoNothingAction
  10024. * @param action defines the next action to execute
  10025. * @returns The action passed in
  10026. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10027. */
  10028. then(action: IAction): IAction;
  10029. }
  10030. /**
  10031. * The action to be carried out following a trigger
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10033. */
  10034. export class Action implements IAction {
  10035. /** the trigger, with or without parameters, for the action */
  10036. triggerOptions: any;
  10037. /**
  10038. * Trigger for the action
  10039. */
  10040. trigger: number;
  10041. /**
  10042. * Internal only - manager for action
  10043. * @hidden
  10044. */
  10045. _actionManager: ActionManager;
  10046. private _nextActiveAction;
  10047. private _child;
  10048. private _condition?;
  10049. private _triggerParameter;
  10050. /**
  10051. * An event triggered prior to action being executed.
  10052. */
  10053. onBeforeExecuteObservable: Observable<Action>;
  10054. /**
  10055. * Creates a new Action
  10056. * @param triggerOptions the trigger, with or without parameters, for the action
  10057. * @param condition an optional determinant of action
  10058. */
  10059. constructor(
  10060. /** the trigger, with or without parameters, for the action */
  10061. triggerOptions: any, condition?: Condition);
  10062. /**
  10063. * Internal only
  10064. * @hidden
  10065. */
  10066. _prepare(): void;
  10067. /**
  10068. * Gets the trigger parameters
  10069. * @returns the trigger parameters
  10070. */
  10071. getTriggerParameter(): any;
  10072. /**
  10073. * Internal only - executes current action event
  10074. * @hidden
  10075. */
  10076. _executeCurrent(evt?: ActionEvent): void;
  10077. /**
  10078. * Execute placeholder for child classes
  10079. * @param evt optional action event
  10080. */
  10081. execute(evt?: ActionEvent): void;
  10082. /**
  10083. * Skips to next active action
  10084. */
  10085. skipToNextActiveAction(): void;
  10086. /**
  10087. * Adds action to chain of actions, may be a DoNothingAction
  10088. * @param action defines the next action to execute
  10089. * @returns The action passed in
  10090. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10091. */
  10092. then(action: Action): Action;
  10093. /**
  10094. * Internal only
  10095. * @hidden
  10096. */
  10097. _getProperty(propertyPath: string): string;
  10098. /**
  10099. * Internal only
  10100. * @hidden
  10101. */
  10102. _getEffectiveTarget(target: any, propertyPath: string): any;
  10103. /**
  10104. * Serialize placeholder for child classes
  10105. * @param parent of child
  10106. * @returns the serialized object
  10107. */
  10108. serialize(parent: any): any;
  10109. /**
  10110. * Internal only called by serialize
  10111. * @hidden
  10112. */
  10113. protected _serialize(serializedAction: any, parent?: any): any;
  10114. /**
  10115. * Internal only
  10116. * @hidden
  10117. */
  10118. static _SerializeValueAsString: (value: any) => string;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. static _GetTargetProperty: (target: Node | Scene) => {
  10124. name: string;
  10125. targetType: string;
  10126. value: string;
  10127. };
  10128. }
  10129. }
  10130. declare module BABYLON {
  10131. /**
  10132. * A Condition applied to an Action
  10133. */
  10134. export class Condition {
  10135. /**
  10136. * Internal only - manager for action
  10137. * @hidden
  10138. */
  10139. _actionManager: ActionManager;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _evaluationId: number;
  10145. /**
  10146. * Internal only
  10147. * @hidden
  10148. */
  10149. _currentResult: boolean;
  10150. /**
  10151. * Creates a new Condition
  10152. * @param actionManager the manager of the action the condition is applied to
  10153. */
  10154. constructor(actionManager: ActionManager);
  10155. /**
  10156. * Check if the current condition is valid
  10157. * @returns a boolean
  10158. */
  10159. isValid(): boolean;
  10160. /**
  10161. * Internal only
  10162. * @hidden
  10163. */
  10164. _getProperty(propertyPath: string): string;
  10165. /**
  10166. * Internal only
  10167. * @hidden
  10168. */
  10169. _getEffectiveTarget(target: any, propertyPath: string): any;
  10170. /**
  10171. * Serialize placeholder for child classes
  10172. * @returns the serialized object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Internal only
  10177. * @hidden
  10178. */
  10179. protected _serialize(serializedCondition: any): any;
  10180. }
  10181. /**
  10182. * Defines specific conditional operators as extensions of Condition
  10183. */
  10184. export class ValueCondition extends Condition {
  10185. /** path to specify the property of the target the conditional operator uses */
  10186. propertyPath: string;
  10187. /** the value compared by the conditional operator against the current value of the property */
  10188. value: any;
  10189. /** the conditional operator, default ValueCondition.IsEqual */
  10190. operator: number;
  10191. /**
  10192. * Internal only
  10193. * @hidden
  10194. */
  10195. private static _IsEqual;
  10196. /**
  10197. * Internal only
  10198. * @hidden
  10199. */
  10200. private static _IsDifferent;
  10201. /**
  10202. * Internal only
  10203. * @hidden
  10204. */
  10205. private static _IsGreater;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. private static _IsLesser;
  10211. /**
  10212. * returns the number for IsEqual
  10213. */
  10214. static readonly IsEqual: number;
  10215. /**
  10216. * Returns the number for IsDifferent
  10217. */
  10218. static readonly IsDifferent: number;
  10219. /**
  10220. * Returns the number for IsGreater
  10221. */
  10222. static readonly IsGreater: number;
  10223. /**
  10224. * Returns the number for IsLesser
  10225. */
  10226. static readonly IsLesser: number;
  10227. /**
  10228. * Internal only The action manager for the condition
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. private _target;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. private _effectiveTarget;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. private _property;
  10247. /**
  10248. * Creates a new ValueCondition
  10249. * @param actionManager manager for the action the condition applies to
  10250. * @param target for the action
  10251. * @param propertyPath path to specify the property of the target the conditional operator uses
  10252. * @param value the value compared by the conditional operator against the current value of the property
  10253. * @param operator the conditional operator, default ValueCondition.IsEqual
  10254. */
  10255. constructor(actionManager: ActionManager, target: any,
  10256. /** path to specify the property of the target the conditional operator uses */
  10257. propertyPath: string,
  10258. /** the value compared by the conditional operator against the current value of the property */
  10259. value: any,
  10260. /** the conditional operator, default ValueCondition.IsEqual */
  10261. operator?: number);
  10262. /**
  10263. * Compares the given value with the property value for the specified conditional operator
  10264. * @returns the result of the comparison
  10265. */
  10266. isValid(): boolean;
  10267. /**
  10268. * Serialize the ValueCondition into a JSON compatible object
  10269. * @returns serialization object
  10270. */
  10271. serialize(): any;
  10272. /**
  10273. * Gets the name of the conditional operator for the ValueCondition
  10274. * @param operator the conditional operator
  10275. * @returns the name
  10276. */
  10277. static GetOperatorName(operator: number): string;
  10278. }
  10279. /**
  10280. * Defines a predicate condition as an extension of Condition
  10281. */
  10282. export class PredicateCondition extends Condition {
  10283. /** defines the predicate function used to validate the condition */
  10284. predicate: () => boolean;
  10285. /**
  10286. * Internal only - manager for action
  10287. * @hidden
  10288. */
  10289. _actionManager: ActionManager;
  10290. /**
  10291. * Creates a new PredicateCondition
  10292. * @param actionManager manager for the action the condition applies to
  10293. * @param predicate defines the predicate function used to validate the condition
  10294. */
  10295. constructor(actionManager: ActionManager,
  10296. /** defines the predicate function used to validate the condition */
  10297. predicate: () => boolean);
  10298. /**
  10299. * @returns the validity of the predicate condition
  10300. */
  10301. isValid(): boolean;
  10302. }
  10303. /**
  10304. * Defines a state condition as an extension of Condition
  10305. */
  10306. export class StateCondition extends Condition {
  10307. /** Value to compare with target state */
  10308. value: string;
  10309. /**
  10310. * Internal only - manager for action
  10311. * @hidden
  10312. */
  10313. _actionManager: ActionManager;
  10314. /**
  10315. * Internal only
  10316. * @hidden
  10317. */
  10318. private _target;
  10319. /**
  10320. * Creates a new StateCondition
  10321. * @param actionManager manager for the action the condition applies to
  10322. * @param target of the condition
  10323. * @param value to compare with target state
  10324. */
  10325. constructor(actionManager: ActionManager, target: any,
  10326. /** Value to compare with target state */
  10327. value: string);
  10328. /**
  10329. * Gets a boolean indicating if the current condition is met
  10330. * @returns the validity of the state
  10331. */
  10332. isValid(): boolean;
  10333. /**
  10334. * Serialize the StateCondition into a JSON compatible object
  10335. * @returns serialization object
  10336. */
  10337. serialize(): any;
  10338. }
  10339. }
  10340. declare module BABYLON {
  10341. /**
  10342. * This defines an action responsible to toggle a boolean once triggered.
  10343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10344. */
  10345. export class SwitchBooleanAction extends Action {
  10346. /**
  10347. * The path to the boolean property in the target object
  10348. */
  10349. propertyPath: string;
  10350. private _target;
  10351. private _effectiveTarget;
  10352. private _property;
  10353. /**
  10354. * Instantiate the action
  10355. * @param triggerOptions defines the trigger options
  10356. * @param target defines the object containing the boolean
  10357. * @param propertyPath defines the path to the boolean property in the target object
  10358. * @param condition defines the trigger related conditions
  10359. */
  10360. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10361. /** @hidden */
  10362. _prepare(): void;
  10363. /**
  10364. * Execute the action toggle the boolean value.
  10365. */
  10366. execute(): void;
  10367. /**
  10368. * Serializes the actions and its related information.
  10369. * @param parent defines the object to serialize in
  10370. * @returns the serialized object
  10371. */
  10372. serialize(parent: any): any;
  10373. }
  10374. /**
  10375. * This defines an action responsible to set a the state field of the target
  10376. * to a desired value once triggered.
  10377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10378. */
  10379. export class SetStateAction extends Action {
  10380. /**
  10381. * The value to store in the state field.
  10382. */
  10383. value: string;
  10384. private _target;
  10385. /**
  10386. * Instantiate the action
  10387. * @param triggerOptions defines the trigger options
  10388. * @param target defines the object containing the state property
  10389. * @param value defines the value to store in the state field
  10390. * @param condition defines the trigger related conditions
  10391. */
  10392. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10393. /**
  10394. * Execute the action and store the value on the target state property.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to set a property of the target
  10406. * to a desired value once triggered.
  10407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10408. */
  10409. export class SetValueAction extends Action {
  10410. /**
  10411. * The path of the property to set in the target.
  10412. */
  10413. propertyPath: string;
  10414. /**
  10415. * The value to set in the property
  10416. */
  10417. value: any;
  10418. private _target;
  10419. private _effectiveTarget;
  10420. private _property;
  10421. /**
  10422. * Instantiate the action
  10423. * @param triggerOptions defines the trigger options
  10424. * @param target defines the object containing the property
  10425. * @param propertyPath defines the path of the property to set in the target
  10426. * @param value defines the value to set in the property
  10427. * @param condition defines the trigger related conditions
  10428. */
  10429. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10430. /** @hidden */
  10431. _prepare(): void;
  10432. /**
  10433. * Execute the action and set the targetted property to the desired value.
  10434. */
  10435. execute(): void;
  10436. /**
  10437. * Serializes the actions and its related information.
  10438. * @param parent defines the object to serialize in
  10439. * @returns the serialized object
  10440. */
  10441. serialize(parent: any): any;
  10442. }
  10443. /**
  10444. * This defines an action responsible to increment the target value
  10445. * to a desired value once triggered.
  10446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10447. */
  10448. export class IncrementValueAction extends Action {
  10449. /**
  10450. * The path of the property to increment in the target.
  10451. */
  10452. propertyPath: string;
  10453. /**
  10454. * The value we should increment the property by.
  10455. */
  10456. value: any;
  10457. private _target;
  10458. private _effectiveTarget;
  10459. private _property;
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param target defines the object containing the property
  10464. * @param propertyPath defines the path of the property to increment in the target
  10465. * @param value defines the value value we should increment the property by
  10466. * @param condition defines the trigger related conditions
  10467. */
  10468. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10469. /** @hidden */
  10470. _prepare(): void;
  10471. /**
  10472. * Execute the action and increment the target of the value amount.
  10473. */
  10474. execute(): void;
  10475. /**
  10476. * Serializes the actions and its related information.
  10477. * @param parent defines the object to serialize in
  10478. * @returns the serialized object
  10479. */
  10480. serialize(parent: any): any;
  10481. }
  10482. /**
  10483. * This defines an action responsible to start an animation once triggered.
  10484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10485. */
  10486. export class PlayAnimationAction extends Action {
  10487. /**
  10488. * Where the animation should start (animation frame)
  10489. */
  10490. from: number;
  10491. /**
  10492. * Where the animation should stop (animation frame)
  10493. */
  10494. to: number;
  10495. /**
  10496. * Define if the animation should loop or stop after the first play.
  10497. */
  10498. loop?: boolean;
  10499. private _target;
  10500. /**
  10501. * Instantiate the action
  10502. * @param triggerOptions defines the trigger options
  10503. * @param target defines the target animation or animation name
  10504. * @param from defines from where the animation should start (animation frame)
  10505. * @param end defines where the animation should stop (animation frame)
  10506. * @param loop defines if the animation should loop or stop after the first play
  10507. * @param condition defines the trigger related conditions
  10508. */
  10509. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10510. /** @hidden */
  10511. _prepare(): void;
  10512. /**
  10513. * Execute the action and play the animation.
  10514. */
  10515. execute(): void;
  10516. /**
  10517. * Serializes the actions and its related information.
  10518. * @param parent defines the object to serialize in
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. }
  10523. /**
  10524. * This defines an action responsible to stop an animation once triggered.
  10525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10526. */
  10527. export class StopAnimationAction extends Action {
  10528. private _target;
  10529. /**
  10530. * Instantiate the action
  10531. * @param triggerOptions defines the trigger options
  10532. * @param target defines the target animation or animation name
  10533. * @param condition defines the trigger related conditions
  10534. */
  10535. constructor(triggerOptions: any, target: any, condition?: Condition);
  10536. /** @hidden */
  10537. _prepare(): void;
  10538. /**
  10539. * Execute the action and stop the animation.
  10540. */
  10541. execute(): void;
  10542. /**
  10543. * Serializes the actions and its related information.
  10544. * @param parent defines the object to serialize in
  10545. * @returns the serialized object
  10546. */
  10547. serialize(parent: any): any;
  10548. }
  10549. /**
  10550. * This defines an action responsible that does nothing once triggered.
  10551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10552. */
  10553. export class DoNothingAction extends Action {
  10554. /**
  10555. * Instantiate the action
  10556. * @param triggerOptions defines the trigger options
  10557. * @param condition defines the trigger related conditions
  10558. */
  10559. constructor(triggerOptions?: any, condition?: Condition);
  10560. /**
  10561. * Execute the action and do nothing.
  10562. */
  10563. execute(): void;
  10564. /**
  10565. * Serializes the actions and its related information.
  10566. * @param parent defines the object to serialize in
  10567. * @returns the serialized object
  10568. */
  10569. serialize(parent: any): any;
  10570. }
  10571. /**
  10572. * This defines an action responsible to trigger several actions once triggered.
  10573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10574. */
  10575. export class CombineAction extends Action {
  10576. /**
  10577. * The list of aggregated animations to run.
  10578. */
  10579. children: Action[];
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param children defines the list of aggregated animations to run
  10584. * @param condition defines the trigger related conditions
  10585. */
  10586. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10587. /** @hidden */
  10588. _prepare(): void;
  10589. /**
  10590. * Execute the action and executes all the aggregated actions.
  10591. */
  10592. execute(evt: ActionEvent): void;
  10593. /**
  10594. * Serializes the actions and its related information.
  10595. * @param parent defines the object to serialize in
  10596. * @returns the serialized object
  10597. */
  10598. serialize(parent: any): any;
  10599. }
  10600. /**
  10601. * This defines an action responsible to run code (external event) once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class ExecuteCodeAction extends Action {
  10605. /**
  10606. * The callback function to run.
  10607. */
  10608. func: (evt: ActionEvent) => void;
  10609. /**
  10610. * Instantiate the action
  10611. * @param triggerOptions defines the trigger options
  10612. * @param func defines the callback function to run
  10613. * @param condition defines the trigger related conditions
  10614. */
  10615. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10616. /**
  10617. * Execute the action and run the attached code.
  10618. */
  10619. execute(evt: ActionEvent): void;
  10620. }
  10621. /**
  10622. * This defines an action responsible to set the parent property of the target once triggered.
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10624. */
  10625. export class SetParentAction extends Action {
  10626. private _parent;
  10627. private _target;
  10628. /**
  10629. * Instantiate the action
  10630. * @param triggerOptions defines the trigger options
  10631. * @param target defines the target containing the parent property
  10632. * @param parent defines from where the animation should start (animation frame)
  10633. * @param condition defines the trigger related conditions
  10634. */
  10635. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10636. /** @hidden */
  10637. _prepare(): void;
  10638. /**
  10639. * Execute the action and set the parent property.
  10640. */
  10641. execute(): void;
  10642. /**
  10643. * Serializes the actions and its related information.
  10644. * @param parent defines the object to serialize in
  10645. * @returns the serialized object
  10646. */
  10647. serialize(parent: any): any;
  10648. }
  10649. }
  10650. declare module BABYLON {
  10651. /**
  10652. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10653. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10655. */
  10656. export class ActionManager extends AbstractActionManager {
  10657. /**
  10658. * Nothing
  10659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10660. */
  10661. static readonly NothingTrigger: number;
  10662. /**
  10663. * On pick
  10664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10665. */
  10666. static readonly OnPickTrigger: number;
  10667. /**
  10668. * On left pick
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10670. */
  10671. static readonly OnLeftPickTrigger: number;
  10672. /**
  10673. * On right pick
  10674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10675. */
  10676. static readonly OnRightPickTrigger: number;
  10677. /**
  10678. * On center pick
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10680. */
  10681. static readonly OnCenterPickTrigger: number;
  10682. /**
  10683. * On pick down
  10684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10685. */
  10686. static readonly OnPickDownTrigger: number;
  10687. /**
  10688. * On double pick
  10689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10690. */
  10691. static readonly OnDoublePickTrigger: number;
  10692. /**
  10693. * On pick up
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10695. */
  10696. static readonly OnPickUpTrigger: number;
  10697. /**
  10698. * On pick out.
  10699. * This trigger will only be raised if you also declared a OnPickDown
  10700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10701. */
  10702. static readonly OnPickOutTrigger: number;
  10703. /**
  10704. * On long press
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10706. */
  10707. static readonly OnLongPressTrigger: number;
  10708. /**
  10709. * On pointer over
  10710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10711. */
  10712. static readonly OnPointerOverTrigger: number;
  10713. /**
  10714. * On pointer out
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10716. */
  10717. static readonly OnPointerOutTrigger: number;
  10718. /**
  10719. * On every frame
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10721. */
  10722. static readonly OnEveryFrameTrigger: number;
  10723. /**
  10724. * On intersection enter
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10726. */
  10727. static readonly OnIntersectionEnterTrigger: number;
  10728. /**
  10729. * On intersection exit
  10730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10731. */
  10732. static readonly OnIntersectionExitTrigger: number;
  10733. /**
  10734. * On key down
  10735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10736. */
  10737. static readonly OnKeyDownTrigger: number;
  10738. /**
  10739. * On key up
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10741. */
  10742. static readonly OnKeyUpTrigger: number;
  10743. private _scene;
  10744. /**
  10745. * Creates a new action manager
  10746. * @param scene defines the hosting scene
  10747. */
  10748. constructor(scene: Scene);
  10749. /**
  10750. * Releases all associated resources
  10751. */
  10752. dispose(): void;
  10753. /**
  10754. * Gets hosting scene
  10755. * @returns the hosting scene
  10756. */
  10757. getScene(): Scene;
  10758. /**
  10759. * Does this action manager handles actions of any of the given triggers
  10760. * @param triggers defines the triggers to be tested
  10761. * @return a boolean indicating whether one (or more) of the triggers is handled
  10762. */
  10763. hasSpecificTriggers(triggers: number[]): boolean;
  10764. /**
  10765. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10766. * speed.
  10767. * @param triggerA defines the trigger to be tested
  10768. * @param triggerB defines the trigger to be tested
  10769. * @return a boolean indicating whether one (or more) of the triggers is handled
  10770. */
  10771. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10772. /**
  10773. * Does this action manager handles actions of a given trigger
  10774. * @param trigger defines the trigger to be tested
  10775. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10776. * @return whether the trigger is handled
  10777. */
  10778. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10779. /**
  10780. * Does this action manager has pointer triggers
  10781. */
  10782. readonly hasPointerTriggers: boolean;
  10783. /**
  10784. * Does this action manager has pick triggers
  10785. */
  10786. readonly hasPickTriggers: boolean;
  10787. /**
  10788. * Registers an action to this action manager
  10789. * @param action defines the action to be registered
  10790. * @return the action amended (prepared) after registration
  10791. */
  10792. registerAction(action: IAction): Nullable<IAction>;
  10793. /**
  10794. * Unregisters an action to this action manager
  10795. * @param action defines the action to be unregistered
  10796. * @return a boolean indicating whether the action has been unregistered
  10797. */
  10798. unregisterAction(action: IAction): Boolean;
  10799. /**
  10800. * Process a specific trigger
  10801. * @param trigger defines the trigger to process
  10802. * @param evt defines the event details to be processed
  10803. */
  10804. processTrigger(trigger: number, evt?: IActionEvent): void;
  10805. /** @hidden */
  10806. _getEffectiveTarget(target: any, propertyPath: string): any;
  10807. /** @hidden */
  10808. _getProperty(propertyPath: string): string;
  10809. /**
  10810. * Serialize this manager to a JSON object
  10811. * @param name defines the property name to store this manager
  10812. * @returns a JSON representation of this manager
  10813. */
  10814. serialize(name: string): any;
  10815. /**
  10816. * Creates a new ActionManager from a JSON data
  10817. * @param parsedActions defines the JSON data to read from
  10818. * @param object defines the hosting mesh
  10819. * @param scene defines the hosting scene
  10820. */
  10821. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10822. /**
  10823. * Get a trigger name by index
  10824. * @param trigger defines the trigger index
  10825. * @returns a trigger name
  10826. */
  10827. static GetTriggerName(trigger: number): string;
  10828. }
  10829. }
  10830. declare module BABYLON {
  10831. /**
  10832. * Class representing a ray with position and direction
  10833. */
  10834. export class Ray {
  10835. /** origin point */
  10836. origin: Vector3;
  10837. /** direction */
  10838. direction: Vector3;
  10839. /** length of the ray */
  10840. length: number;
  10841. private static readonly TmpVector3;
  10842. private _tmpRay;
  10843. /**
  10844. * Creates a new ray
  10845. * @param origin origin point
  10846. * @param direction direction
  10847. * @param length length of the ray
  10848. */
  10849. constructor(
  10850. /** origin point */
  10851. origin: Vector3,
  10852. /** direction */
  10853. direction: Vector3,
  10854. /** length of the ray */
  10855. length?: number);
  10856. /**
  10857. * Checks if the ray intersects a box
  10858. * @param minimum bound of the box
  10859. * @param maximum bound of the box
  10860. * @param intersectionTreshold extra extend to be added to the box in all direction
  10861. * @returns if the box was hit
  10862. */
  10863. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10864. /**
  10865. * Checks if the ray intersects a box
  10866. * @param box the bounding box to check
  10867. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10868. * @returns if the box was hit
  10869. */
  10870. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10871. /**
  10872. * If the ray hits a sphere
  10873. * @param sphere the bounding sphere to check
  10874. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10875. * @returns true if it hits the sphere
  10876. */
  10877. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10878. /**
  10879. * If the ray hits a triange
  10880. * @param vertex0 triangle vertex
  10881. * @param vertex1 triangle vertex
  10882. * @param vertex2 triangle vertex
  10883. * @returns intersection information if hit
  10884. */
  10885. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10886. /**
  10887. * Checks if ray intersects a plane
  10888. * @param plane the plane to check
  10889. * @returns the distance away it was hit
  10890. */
  10891. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10892. /**
  10893. * Calculate the intercept of a ray on a given axis
  10894. * @param axis to check 'x' | 'y' | 'z'
  10895. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10896. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10897. */
  10898. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10899. /**
  10900. * Checks if ray intersects a mesh
  10901. * @param mesh the mesh to check
  10902. * @param fastCheck if only the bounding box should checked
  10903. * @returns picking info of the intersecton
  10904. */
  10905. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10906. /**
  10907. * Checks if ray intersects a mesh
  10908. * @param meshes the meshes to check
  10909. * @param fastCheck if only the bounding box should checked
  10910. * @param results array to store result in
  10911. * @returns Array of picking infos
  10912. */
  10913. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10914. private _comparePickingInfo;
  10915. private static smallnum;
  10916. private static rayl;
  10917. /**
  10918. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10919. * @param sega the first point of the segment to test the intersection against
  10920. * @param segb the second point of the segment to test the intersection against
  10921. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10922. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10923. */
  10924. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10925. /**
  10926. * Update the ray from viewport position
  10927. * @param x position
  10928. * @param y y position
  10929. * @param viewportWidth viewport width
  10930. * @param viewportHeight viewport height
  10931. * @param world world matrix
  10932. * @param view view matrix
  10933. * @param projection projection matrix
  10934. * @returns this ray updated
  10935. */
  10936. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10937. /**
  10938. * Creates a ray with origin and direction of 0,0,0
  10939. * @returns the new ray
  10940. */
  10941. static Zero(): Ray;
  10942. /**
  10943. * Creates a new ray from screen space and viewport
  10944. * @param x position
  10945. * @param y y position
  10946. * @param viewportWidth viewport width
  10947. * @param viewportHeight viewport height
  10948. * @param world world matrix
  10949. * @param view view matrix
  10950. * @param projection projection matrix
  10951. * @returns new ray
  10952. */
  10953. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10954. /**
  10955. * 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
  10956. * transformed to the given world matrix.
  10957. * @param origin The origin point
  10958. * @param end The end point
  10959. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10960. * @returns the new ray
  10961. */
  10962. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10963. /**
  10964. * Transforms a ray by a matrix
  10965. * @param ray ray to transform
  10966. * @param matrix matrix to apply
  10967. * @returns the resulting new ray
  10968. */
  10969. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10970. /**
  10971. * Transforms a ray by a matrix
  10972. * @param ray ray to transform
  10973. * @param matrix matrix to apply
  10974. * @param result ray to store result in
  10975. */
  10976. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10977. /**
  10978. * Unproject a ray from screen space to object space
  10979. * @param sourceX defines the screen space x coordinate to use
  10980. * @param sourceY defines the screen space y coordinate to use
  10981. * @param viewportWidth defines the current width of the viewport
  10982. * @param viewportHeight defines the current height of the viewport
  10983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10984. * @param view defines the view matrix to use
  10985. * @param projection defines the projection matrix to use
  10986. */
  10987. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10988. }
  10989. /**
  10990. * Type used to define predicate used to select faces when a mesh intersection is detected
  10991. */
  10992. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10993. interface Scene {
  10994. /** @hidden */
  10995. _tempPickingRay: Nullable<Ray>;
  10996. /** @hidden */
  10997. _cachedRayForTransform: Ray;
  10998. /** @hidden */
  10999. _pickWithRayInverseMatrix: Matrix;
  11000. /** @hidden */
  11001. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11002. /** @hidden */
  11003. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11004. }
  11005. }
  11006. declare module BABYLON {
  11007. /**
  11008. * Groups all the scene component constants in one place to ease maintenance.
  11009. * @hidden
  11010. */
  11011. export class SceneComponentConstants {
  11012. static readonly NAME_EFFECTLAYER: string;
  11013. static readonly NAME_LAYER: string;
  11014. static readonly NAME_LENSFLARESYSTEM: string;
  11015. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11016. static readonly NAME_PARTICLESYSTEM: string;
  11017. static readonly NAME_GAMEPAD: string;
  11018. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11019. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11020. static readonly NAME_DEPTHRENDERER: string;
  11021. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11022. static readonly NAME_SPRITE: string;
  11023. static readonly NAME_OUTLINERENDERER: string;
  11024. static readonly NAME_PROCEDURALTEXTURE: string;
  11025. static readonly NAME_SHADOWGENERATOR: string;
  11026. static readonly NAME_OCTREE: string;
  11027. static readonly NAME_PHYSICSENGINE: string;
  11028. static readonly NAME_AUDIO: string;
  11029. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11030. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11033. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11038. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11040. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11041. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11042. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11043. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11044. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11045. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11046. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11049. static readonly STEP_AFTERRENDER_AUDIO: number;
  11050. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11051. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11052. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11054. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11055. static readonly STEP_POINTERMOVE_SPRITE: number;
  11056. static readonly STEP_POINTERDOWN_SPRITE: number;
  11057. static readonly STEP_POINTERUP_SPRITE: number;
  11058. }
  11059. /**
  11060. * This represents a scene component.
  11061. *
  11062. * This is used to decouple the dependency the scene is having on the different workloads like
  11063. * layers, post processes...
  11064. */
  11065. export interface ISceneComponent {
  11066. /**
  11067. * The name of the component. Each component must have a unique name.
  11068. */
  11069. name: string;
  11070. /**
  11071. * The scene the component belongs to.
  11072. */
  11073. scene: Scene;
  11074. /**
  11075. * Register the component to one instance of a scene.
  11076. */
  11077. register(): void;
  11078. /**
  11079. * Rebuilds the elements related to this component in case of
  11080. * context lost for instance.
  11081. */
  11082. rebuild(): void;
  11083. /**
  11084. * Disposes the component and the associated ressources.
  11085. */
  11086. dispose(): void;
  11087. }
  11088. /**
  11089. * This represents a SERIALIZABLE scene component.
  11090. *
  11091. * This extends Scene Component to add Serialization methods on top.
  11092. */
  11093. export interface ISceneSerializableComponent extends ISceneComponent {
  11094. /**
  11095. * Adds all the elements from the container to the scene
  11096. * @param container the container holding the elements
  11097. */
  11098. addFromContainer(container: AbstractScene): void;
  11099. /**
  11100. * Removes all the elements in the container from the scene
  11101. * @param container contains the elements to remove
  11102. * @param dispose if the removed element should be disposed (default: false)
  11103. */
  11104. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11105. /**
  11106. * Serializes the component data to the specified json object
  11107. * @param serializationObject The object to serialize to
  11108. */
  11109. serialize(serializationObject: any): void;
  11110. }
  11111. /**
  11112. * Strong typing of a Mesh related stage step action
  11113. */
  11114. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11115. /**
  11116. * Strong typing of a Evaluate Sub Mesh related stage step action
  11117. */
  11118. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11119. /**
  11120. * Strong typing of a Active Mesh related stage step action
  11121. */
  11122. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11123. /**
  11124. * Strong typing of a Camera related stage step action
  11125. */
  11126. export type CameraStageAction = (camera: Camera) => void;
  11127. /**
  11128. * Strong typing of a Camera Frame buffer related stage step action
  11129. */
  11130. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11131. /**
  11132. * Strong typing of a Render Target related stage step action
  11133. */
  11134. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11135. /**
  11136. * Strong typing of a RenderingGroup related stage step action
  11137. */
  11138. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11139. /**
  11140. * Strong typing of a Mesh Render related stage step action
  11141. */
  11142. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11143. /**
  11144. * Strong typing of a simple stage step action
  11145. */
  11146. export type SimpleStageAction = () => void;
  11147. /**
  11148. * Strong typing of a render target action.
  11149. */
  11150. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11151. /**
  11152. * Strong typing of a pointer move action.
  11153. */
  11154. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11155. /**
  11156. * Strong typing of a pointer up/down action.
  11157. */
  11158. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11159. /**
  11160. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11161. * @hidden
  11162. */
  11163. export class Stage<T extends Function> extends Array<{
  11164. index: number;
  11165. component: ISceneComponent;
  11166. action: T;
  11167. }> {
  11168. /**
  11169. * Hide ctor from the rest of the world.
  11170. * @param items The items to add.
  11171. */
  11172. private constructor();
  11173. /**
  11174. * Creates a new Stage.
  11175. * @returns A new instance of a Stage
  11176. */
  11177. static Create<T extends Function>(): Stage<T>;
  11178. /**
  11179. * Registers a step in an ordered way in the targeted stage.
  11180. * @param index Defines the position to register the step in
  11181. * @param component Defines the component attached to the step
  11182. * @param action Defines the action to launch during the step
  11183. */
  11184. registerStep(index: number, component: ISceneComponent, action: T): void;
  11185. /**
  11186. * Clears all the steps from the stage.
  11187. */
  11188. clear(): void;
  11189. }
  11190. }
  11191. declare module BABYLON {
  11192. interface Scene {
  11193. /** @hidden */
  11194. _pointerOverSprite: Nullable<Sprite>;
  11195. /** @hidden */
  11196. _pickedDownSprite: Nullable<Sprite>;
  11197. /** @hidden */
  11198. _tempSpritePickingRay: Nullable<Ray>;
  11199. /**
  11200. * All of the sprite managers added to this scene
  11201. * @see http://doc.babylonjs.com/babylon101/sprites
  11202. */
  11203. spriteManagers: Array<ISpriteManager>;
  11204. /**
  11205. * An event triggered when sprites rendering is about to start
  11206. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11207. */
  11208. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11209. /**
  11210. * An event triggered when sprites rendering is done
  11211. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11212. */
  11213. onAfterSpritesRenderingObservable: Observable<Scene>;
  11214. /** @hidden */
  11215. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11216. /** Launch a ray to try to pick a sprite in the scene
  11217. * @param x position on screen
  11218. * @param y position on screen
  11219. * @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
  11220. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11221. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11222. * @returns a PickingInfo
  11223. */
  11224. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11225. /** Use the given ray to pick a sprite in the scene
  11226. * @param ray The ray (in world space) to use to pick meshes
  11227. * @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
  11228. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11229. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11230. * @returns a PickingInfo
  11231. */
  11232. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11233. /** @hidden */
  11234. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11235. /** Launch a ray to try to pick sprites in the scene
  11236. * @param x position on screen
  11237. * @param y position on screen
  11238. * @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
  11239. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11240. * @returns a PickingInfo array
  11241. */
  11242. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11243. /** Use the given ray to pick sprites in the scene
  11244. * @param ray The ray (in world space) to use to pick meshes
  11245. * @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
  11246. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11247. * @returns a PickingInfo array
  11248. */
  11249. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11250. /**
  11251. * Force the sprite under the pointer
  11252. * @param sprite defines the sprite to use
  11253. */
  11254. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11255. /**
  11256. * Gets the sprite under the pointer
  11257. * @returns a Sprite or null if no sprite is under the pointer
  11258. */
  11259. getPointerOverSprite(): Nullable<Sprite>;
  11260. }
  11261. /**
  11262. * Defines the sprite scene component responsible to manage sprites
  11263. * in a given scene.
  11264. */
  11265. export class SpriteSceneComponent implements ISceneComponent {
  11266. /**
  11267. * The component name helpfull to identify the component in the list of scene components.
  11268. */
  11269. readonly name: string;
  11270. /**
  11271. * The scene the component belongs to.
  11272. */
  11273. scene: Scene;
  11274. /** @hidden */
  11275. private _spritePredicate;
  11276. /**
  11277. * Creates a new instance of the component for the given scene
  11278. * @param scene Defines the scene to register the component in
  11279. */
  11280. constructor(scene: Scene);
  11281. /**
  11282. * Registers the component in a given scene
  11283. */
  11284. register(): void;
  11285. /**
  11286. * Rebuilds the elements related to this component in case of
  11287. * context lost for instance.
  11288. */
  11289. rebuild(): void;
  11290. /**
  11291. * Disposes the component and the associated ressources.
  11292. */
  11293. dispose(): void;
  11294. private _pickSpriteButKeepRay;
  11295. private _pointerMove;
  11296. private _pointerDown;
  11297. private _pointerUp;
  11298. }
  11299. }
  11300. declare module BABYLON {
  11301. /** @hidden */
  11302. export var fogFragmentDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module BABYLON {
  11308. /** @hidden */
  11309. export var fogFragment: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module BABYLON {
  11315. /** @hidden */
  11316. export var spritesPixelShader: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module BABYLON {
  11322. /** @hidden */
  11323. export var fogVertexDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module BABYLON {
  11329. /** @hidden */
  11330. export var spritesVertexShader: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module BABYLON {
  11336. /**
  11337. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11338. */
  11339. export interface ISpriteManager extends IDisposable {
  11340. /**
  11341. * Restricts the camera to viewing objects with the same layerMask.
  11342. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11343. */
  11344. layerMask: number;
  11345. /**
  11346. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11347. */
  11348. isPickable: boolean;
  11349. /**
  11350. * Specifies the rendering group id for this mesh (0 by default)
  11351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11352. */
  11353. renderingGroupId: number;
  11354. /**
  11355. * Defines the list of sprites managed by the manager.
  11356. */
  11357. sprites: Array<Sprite>;
  11358. /**
  11359. * Tests the intersection of a sprite with a specific ray.
  11360. * @param ray The ray we are sending to test the collision
  11361. * @param camera The camera space we are sending rays in
  11362. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11363. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11364. * @returns picking info or null.
  11365. */
  11366. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11367. /**
  11368. * Intersects the sprites with a ray
  11369. * @param ray defines the ray to intersect with
  11370. * @param camera defines the current active camera
  11371. * @param predicate defines a predicate used to select candidate sprites
  11372. * @returns null if no hit or a PickingInfo array
  11373. */
  11374. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11375. /**
  11376. * Renders the list of sprites on screen.
  11377. */
  11378. render(): void;
  11379. }
  11380. /**
  11381. * Class used to manage multiple sprites on the same spritesheet
  11382. * @see http://doc.babylonjs.com/babylon101/sprites
  11383. */
  11384. export class SpriteManager implements ISpriteManager {
  11385. /** defines the manager's name */
  11386. name: string;
  11387. /** Gets the list of sprites */
  11388. sprites: Sprite[];
  11389. /** Gets or sets the rendering group id (0 by default) */
  11390. renderingGroupId: number;
  11391. /** Gets or sets camera layer mask */
  11392. layerMask: number;
  11393. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11394. fogEnabled: boolean;
  11395. /** Gets or sets a boolean indicating if the sprites are pickable */
  11396. isPickable: boolean;
  11397. /** Defines the default width of a cell in the spritesheet */
  11398. cellWidth: number;
  11399. /** Defines the default height of a cell in the spritesheet */
  11400. cellHeight: number;
  11401. /** Associative array from JSON sprite data file */
  11402. private _cellData;
  11403. /** Array of sprite names from JSON sprite data file */
  11404. private _spriteMap;
  11405. /** True when packed cell data from JSON file is ready*/
  11406. private _packedAndReady;
  11407. /**
  11408. * An event triggered when the manager is disposed.
  11409. */
  11410. onDisposeObservable: Observable<SpriteManager>;
  11411. private _onDisposeObserver;
  11412. /**
  11413. * Callback called when the manager is disposed
  11414. */
  11415. onDispose: () => void;
  11416. private _capacity;
  11417. private _fromPacked;
  11418. private _spriteTexture;
  11419. private _epsilon;
  11420. private _scene;
  11421. private _vertexData;
  11422. private _buffer;
  11423. private _vertexBuffers;
  11424. private _indexBuffer;
  11425. private _effectBase;
  11426. private _effectFog;
  11427. /**
  11428. * Gets or sets the spritesheet texture
  11429. */
  11430. texture: Texture;
  11431. /**
  11432. * Creates a new sprite manager
  11433. * @param name defines the manager's name
  11434. * @param imgUrl defines the sprite sheet url
  11435. * @param capacity defines the maximum allowed number of sprites
  11436. * @param cellSize defines the size of a sprite cell
  11437. * @param scene defines the hosting scene
  11438. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11439. * @param samplingMode defines the smapling mode to use with spritesheet
  11440. * @param fromPacked set to false; do not alter
  11441. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11442. */
  11443. constructor(
  11444. /** defines the manager's name */
  11445. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11446. private _makePacked;
  11447. private _appendSpriteVertex;
  11448. /**
  11449. * Intersects the sprites with a ray
  11450. * @param ray defines the ray to intersect with
  11451. * @param camera defines the current active camera
  11452. * @param predicate defines a predicate used to select candidate sprites
  11453. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11454. * @returns null if no hit or a PickingInfo
  11455. */
  11456. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11457. /**
  11458. * Intersects the sprites with a ray
  11459. * @param ray defines the ray to intersect with
  11460. * @param camera defines the current active camera
  11461. * @param predicate defines a predicate used to select candidate sprites
  11462. * @returns null if no hit or a PickingInfo array
  11463. */
  11464. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11465. /**
  11466. * Render all child sprites
  11467. */
  11468. render(): void;
  11469. /**
  11470. * Release associated resources
  11471. */
  11472. dispose(): void;
  11473. }
  11474. }
  11475. declare module BABYLON {
  11476. /**
  11477. * Class used to represent a sprite
  11478. * @see http://doc.babylonjs.com/babylon101/sprites
  11479. */
  11480. export class Sprite {
  11481. /** defines the name */
  11482. name: string;
  11483. /** Gets or sets the current world position */
  11484. position: Vector3;
  11485. /** Gets or sets the main color */
  11486. color: Color4;
  11487. /** Gets or sets the width */
  11488. width: number;
  11489. /** Gets or sets the height */
  11490. height: number;
  11491. /** Gets or sets rotation angle */
  11492. angle: number;
  11493. /** Gets or sets the cell index in the sprite sheet */
  11494. cellIndex: number;
  11495. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11496. cellRef: string;
  11497. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11498. invertU: number;
  11499. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11500. invertV: number;
  11501. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11502. disposeWhenFinishedAnimating: boolean;
  11503. /** Gets the list of attached animations */
  11504. animations: Animation[];
  11505. /** Gets or sets a boolean indicating if the sprite can be picked */
  11506. isPickable: boolean;
  11507. /**
  11508. * Gets or sets the associated action manager
  11509. */
  11510. actionManager: Nullable<ActionManager>;
  11511. private _animationStarted;
  11512. private _loopAnimation;
  11513. private _fromIndex;
  11514. private _toIndex;
  11515. private _delay;
  11516. private _direction;
  11517. private _manager;
  11518. private _time;
  11519. private _onAnimationEnd;
  11520. /**
  11521. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11522. */
  11523. isVisible: boolean;
  11524. /**
  11525. * Gets or sets the sprite size
  11526. */
  11527. size: number;
  11528. /**
  11529. * Creates a new Sprite
  11530. * @param name defines the name
  11531. * @param manager defines the manager
  11532. */
  11533. constructor(
  11534. /** defines the name */
  11535. name: string, manager: ISpriteManager);
  11536. /**
  11537. * Starts an animation
  11538. * @param from defines the initial key
  11539. * @param to defines the end key
  11540. * @param loop defines if the animation must loop
  11541. * @param delay defines the start delay (in ms)
  11542. * @param onAnimationEnd defines a callback to call when animation ends
  11543. */
  11544. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11545. /** Stops current animation (if any) */
  11546. stopAnimation(): void;
  11547. /** @hidden */
  11548. _animate(deltaTime: number): void;
  11549. /** Release associated resources */
  11550. dispose(): void;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Information about the result of picking within a scene
  11556. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11557. */
  11558. export class PickingInfo {
  11559. /** @hidden */
  11560. _pickingUnavailable: boolean;
  11561. /**
  11562. * If the pick collided with an object
  11563. */
  11564. hit: boolean;
  11565. /**
  11566. * Distance away where the pick collided
  11567. */
  11568. distance: number;
  11569. /**
  11570. * The location of pick collision
  11571. */
  11572. pickedPoint: Nullable<Vector3>;
  11573. /**
  11574. * The mesh corresponding the the pick collision
  11575. */
  11576. pickedMesh: Nullable<AbstractMesh>;
  11577. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11578. bu: number;
  11579. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11580. bv: number;
  11581. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11582. faceId: number;
  11583. /** Id of the the submesh that was picked */
  11584. subMeshId: number;
  11585. /** If a sprite was picked, this will be the sprite the pick collided with */
  11586. pickedSprite: Nullable<Sprite>;
  11587. /**
  11588. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11589. */
  11590. originMesh: Nullable<AbstractMesh>;
  11591. /**
  11592. * The ray that was used to perform the picking.
  11593. */
  11594. ray: Nullable<Ray>;
  11595. /**
  11596. * Gets the normal correspodning to the face the pick collided with
  11597. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11598. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11599. * @returns The normal correspodning to the face the pick collided with
  11600. */
  11601. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11602. /**
  11603. * Gets the texture coordinates of where the pick occured
  11604. * @returns the vector containing the coordnates of the texture
  11605. */
  11606. getTextureCoordinates(): Nullable<Vector2>;
  11607. }
  11608. }
  11609. declare module BABYLON {
  11610. /**
  11611. * Gather the list of pointer event types as constants.
  11612. */
  11613. export class PointerEventTypes {
  11614. /**
  11615. * 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.
  11616. */
  11617. static readonly POINTERDOWN: number;
  11618. /**
  11619. * The pointerup event is fired when a pointer is no longer active.
  11620. */
  11621. static readonly POINTERUP: number;
  11622. /**
  11623. * The pointermove event is fired when a pointer changes coordinates.
  11624. */
  11625. static readonly POINTERMOVE: number;
  11626. /**
  11627. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11628. */
  11629. static readonly POINTERWHEEL: number;
  11630. /**
  11631. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11632. */
  11633. static readonly POINTERPICK: number;
  11634. /**
  11635. * The pointertap event is fired when a the object has been touched and released without drag.
  11636. */
  11637. static readonly POINTERTAP: number;
  11638. /**
  11639. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11640. */
  11641. static readonly POINTERDOUBLETAP: number;
  11642. }
  11643. /**
  11644. * Base class of pointer info types.
  11645. */
  11646. export class PointerInfoBase {
  11647. /**
  11648. * Defines the type of event (PointerEventTypes)
  11649. */
  11650. type: number;
  11651. /**
  11652. * Defines the related dom event
  11653. */
  11654. event: PointerEvent | MouseWheelEvent;
  11655. /**
  11656. * Instantiates the base class of pointers info.
  11657. * @param type Defines the type of event (PointerEventTypes)
  11658. * @param event Defines the related dom event
  11659. */
  11660. constructor(
  11661. /**
  11662. * Defines the type of event (PointerEventTypes)
  11663. */
  11664. type: number,
  11665. /**
  11666. * Defines the related dom event
  11667. */
  11668. event: PointerEvent | MouseWheelEvent);
  11669. }
  11670. /**
  11671. * This class is used to store pointer related info for the onPrePointerObservable event.
  11672. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11673. */
  11674. export class PointerInfoPre extends PointerInfoBase {
  11675. /**
  11676. * Ray from a pointer if availible (eg. 6dof controller)
  11677. */
  11678. ray: Nullable<Ray>;
  11679. /**
  11680. * Defines the local position of the pointer on the canvas.
  11681. */
  11682. localPosition: Vector2;
  11683. /**
  11684. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11685. */
  11686. skipOnPointerObservable: boolean;
  11687. /**
  11688. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11689. * @param type Defines the type of event (PointerEventTypes)
  11690. * @param event Defines the related dom event
  11691. * @param localX Defines the local x coordinates of the pointer when the event occured
  11692. * @param localY Defines the local y coordinates of the pointer when the event occured
  11693. */
  11694. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11695. }
  11696. /**
  11697. * This type contains all the data related to a pointer event in Babylon.js.
  11698. * 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.
  11699. */
  11700. export class PointerInfo extends PointerInfoBase {
  11701. /**
  11702. * Defines the picking info associated to the info (if any)\
  11703. */
  11704. pickInfo: Nullable<PickingInfo>;
  11705. /**
  11706. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11707. * @param type Defines the type of event (PointerEventTypes)
  11708. * @param event Defines the related dom event
  11709. * @param pickInfo Defines the picking info associated to the info (if any)\
  11710. */
  11711. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11712. /**
  11713. * Defines the picking info associated to the info (if any)\
  11714. */
  11715. pickInfo: Nullable<PickingInfo>);
  11716. }
  11717. /**
  11718. * Data relating to a touch event on the screen.
  11719. */
  11720. export interface PointerTouch {
  11721. /**
  11722. * X coordinate of touch.
  11723. */
  11724. x: number;
  11725. /**
  11726. * Y coordinate of touch.
  11727. */
  11728. y: number;
  11729. /**
  11730. * Id of touch. Unique for each finger.
  11731. */
  11732. pointerId: number;
  11733. /**
  11734. * Event type passed from DOM.
  11735. */
  11736. type: any;
  11737. }
  11738. }
  11739. declare module BABYLON {
  11740. /**
  11741. * Manage the mouse inputs to control the movement of a free camera.
  11742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11743. */
  11744. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11745. /**
  11746. * Define if touch is enabled in the mouse input
  11747. */
  11748. touchEnabled: boolean;
  11749. /**
  11750. * Defines the camera the input is attached to.
  11751. */
  11752. camera: FreeCamera;
  11753. /**
  11754. * Defines the buttons associated with the input to handle camera move.
  11755. */
  11756. buttons: number[];
  11757. /**
  11758. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11759. */
  11760. angularSensibility: number;
  11761. private _pointerInput;
  11762. private _onMouseMove;
  11763. private _observer;
  11764. private previousPosition;
  11765. /**
  11766. * Observable for when a pointer move event occurs containing the move offset
  11767. */
  11768. onPointerMovedObservable: Observable<{
  11769. offsetX: number;
  11770. offsetY: number;
  11771. }>;
  11772. /**
  11773. * @hidden
  11774. * If the camera should be rotated automatically based on pointer movement
  11775. */
  11776. _allowCameraRotation: boolean;
  11777. /**
  11778. * Manage the mouse inputs to control the movement of a free camera.
  11779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11780. * @param touchEnabled Defines if touch is enabled or not
  11781. */
  11782. constructor(
  11783. /**
  11784. * Define if touch is enabled in the mouse input
  11785. */
  11786. touchEnabled?: boolean);
  11787. /**
  11788. * Attach the input controls to a specific dom element to get the input from.
  11789. * @param element Defines the element the controls should be listened from
  11790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11791. */
  11792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11793. /**
  11794. * Called on JS contextmenu event.
  11795. * Override this method to provide functionality.
  11796. */
  11797. protected onContextMenu(evt: PointerEvent): void;
  11798. /**
  11799. * Detach the current controls from the specified dom element.
  11800. * @param element Defines the element to stop listening the inputs from
  11801. */
  11802. detachControl(element: Nullable<HTMLElement>): void;
  11803. /**
  11804. * Gets the class name of the current intput.
  11805. * @returns the class name
  11806. */
  11807. getClassName(): string;
  11808. /**
  11809. * Get the friendly name associated with the input class.
  11810. * @returns the input friendly name
  11811. */
  11812. getSimpleName(): string;
  11813. }
  11814. }
  11815. declare module BABYLON {
  11816. /**
  11817. * Manage the touch inputs to control the movement of a free camera.
  11818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11819. */
  11820. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11821. /**
  11822. * Defines the camera the input is attached to.
  11823. */
  11824. camera: FreeCamera;
  11825. /**
  11826. * Defines the touch sensibility for rotation.
  11827. * The higher the faster.
  11828. */
  11829. touchAngularSensibility: number;
  11830. /**
  11831. * Defines the touch sensibility for move.
  11832. * The higher the faster.
  11833. */
  11834. touchMoveSensibility: number;
  11835. private _offsetX;
  11836. private _offsetY;
  11837. private _pointerPressed;
  11838. private _pointerInput;
  11839. private _observer;
  11840. private _onLostFocus;
  11841. /**
  11842. * Attach the input controls to a specific dom element to get the input from.
  11843. * @param element Defines the element the controls should be listened from
  11844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11845. */
  11846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11847. /**
  11848. * Detach the current controls from the specified dom element.
  11849. * @param element Defines the element to stop listening the inputs from
  11850. */
  11851. detachControl(element: Nullable<HTMLElement>): void;
  11852. /**
  11853. * Update the current camera state depending on the inputs that have been used this frame.
  11854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11855. */
  11856. checkInputs(): void;
  11857. /**
  11858. * Gets the class name of the current intput.
  11859. * @returns the class name
  11860. */
  11861. getClassName(): string;
  11862. /**
  11863. * Get the friendly name associated with the input class.
  11864. * @returns the input friendly name
  11865. */
  11866. getSimpleName(): string;
  11867. }
  11868. }
  11869. declare module BABYLON {
  11870. /**
  11871. * Default Inputs manager for the FreeCamera.
  11872. * It groups all the default supported inputs for ease of use.
  11873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11874. */
  11875. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11876. /**
  11877. * @hidden
  11878. */
  11879. _mouseInput: Nullable<FreeCameraMouseInput>;
  11880. /**
  11881. * Instantiates a new FreeCameraInputsManager.
  11882. * @param camera Defines the camera the inputs belong to
  11883. */
  11884. constructor(camera: FreeCamera);
  11885. /**
  11886. * Add keyboard input support to the input manager.
  11887. * @returns the current input manager
  11888. */
  11889. addKeyboard(): FreeCameraInputsManager;
  11890. /**
  11891. * Add mouse input support to the input manager.
  11892. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11893. * @returns the current input manager
  11894. */
  11895. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11896. /**
  11897. * Removes the mouse input support from the manager
  11898. * @returns the current input manager
  11899. */
  11900. removeMouse(): FreeCameraInputsManager;
  11901. /**
  11902. * Add touch input support to the input manager.
  11903. * @returns the current input manager
  11904. */
  11905. addTouch(): FreeCameraInputsManager;
  11906. /**
  11907. * Remove all attached input methods from a camera
  11908. */
  11909. clear(): void;
  11910. }
  11911. }
  11912. declare module BABYLON {
  11913. /**
  11914. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11915. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11916. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11917. */
  11918. export class FreeCamera extends TargetCamera {
  11919. /**
  11920. * Define the collision ellipsoid of the camera.
  11921. * This is helpful to simulate a camera body like the player body around the camera
  11922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11923. */
  11924. ellipsoid: Vector3;
  11925. /**
  11926. * Define an offset for the position of the ellipsoid around the camera.
  11927. * This can be helpful to determine the center of the body near the gravity center of the body
  11928. * instead of its head.
  11929. */
  11930. ellipsoidOffset: Vector3;
  11931. /**
  11932. * Enable or disable collisions of the camera with the rest of the scene objects.
  11933. */
  11934. checkCollisions: boolean;
  11935. /**
  11936. * Enable or disable gravity on the camera.
  11937. */
  11938. applyGravity: boolean;
  11939. /**
  11940. * Define the input manager associated to the camera.
  11941. */
  11942. inputs: FreeCameraInputsManager;
  11943. /**
  11944. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11945. * Higher values reduce sensitivity.
  11946. */
  11947. /**
  11948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11949. * Higher values reduce sensitivity.
  11950. */
  11951. angularSensibility: number;
  11952. /**
  11953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11954. */
  11955. keysUp: number[];
  11956. /**
  11957. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11958. */
  11959. keysDown: number[];
  11960. /**
  11961. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11962. */
  11963. keysLeft: number[];
  11964. /**
  11965. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11966. */
  11967. keysRight: number[];
  11968. /**
  11969. * Event raised when the camera collide with a mesh in the scene.
  11970. */
  11971. onCollide: (collidedMesh: AbstractMesh) => void;
  11972. private _collider;
  11973. private _needMoveForGravity;
  11974. private _oldPosition;
  11975. private _diffPosition;
  11976. private _newPosition;
  11977. /** @hidden */
  11978. _localDirection: Vector3;
  11979. /** @hidden */
  11980. _transformedDirection: Vector3;
  11981. /**
  11982. * Instantiates a Free Camera.
  11983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11984. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11985. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11986. * @param name Define the name of the camera in the scene
  11987. * @param position Define the start position of the camera in the scene
  11988. * @param scene Define the scene the camera belongs to
  11989. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11990. */
  11991. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11992. /**
  11993. * Attached controls to the current camera.
  11994. * @param element Defines the element the controls should be listened from
  11995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11996. */
  11997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11998. /**
  11999. * Detach the current controls from the camera.
  12000. * The camera will stop reacting to inputs.
  12001. * @param element Defines the element to stop listening the inputs from
  12002. */
  12003. detachControl(element: HTMLElement): void;
  12004. private _collisionMask;
  12005. /**
  12006. * Define a collision mask to limit the list of object the camera can collide with
  12007. */
  12008. collisionMask: number;
  12009. /** @hidden */
  12010. _collideWithWorld(displacement: Vector3): void;
  12011. private _onCollisionPositionChange;
  12012. /** @hidden */
  12013. _checkInputs(): void;
  12014. /** @hidden */
  12015. _decideIfNeedsToMove(): boolean;
  12016. /** @hidden */
  12017. _updatePosition(): void;
  12018. /**
  12019. * Destroy the camera and release the current resources hold by it.
  12020. */
  12021. dispose(): void;
  12022. /**
  12023. * Gets the current object class name.
  12024. * @return the class name
  12025. */
  12026. getClassName(): string;
  12027. }
  12028. }
  12029. declare module BABYLON {
  12030. /**
  12031. * Represents a gamepad control stick position
  12032. */
  12033. export class StickValues {
  12034. /**
  12035. * The x component of the control stick
  12036. */
  12037. x: number;
  12038. /**
  12039. * The y component of the control stick
  12040. */
  12041. y: number;
  12042. /**
  12043. * Initializes the gamepad x and y control stick values
  12044. * @param x The x component of the gamepad control stick value
  12045. * @param y The y component of the gamepad control stick value
  12046. */
  12047. constructor(
  12048. /**
  12049. * The x component of the control stick
  12050. */
  12051. x: number,
  12052. /**
  12053. * The y component of the control stick
  12054. */
  12055. y: number);
  12056. }
  12057. /**
  12058. * An interface which manages callbacks for gamepad button changes
  12059. */
  12060. export interface GamepadButtonChanges {
  12061. /**
  12062. * Called when a gamepad has been changed
  12063. */
  12064. changed: boolean;
  12065. /**
  12066. * Called when a gamepad press event has been triggered
  12067. */
  12068. pressChanged: boolean;
  12069. /**
  12070. * Called when a touch event has been triggered
  12071. */
  12072. touchChanged: boolean;
  12073. /**
  12074. * Called when a value has changed
  12075. */
  12076. valueChanged: boolean;
  12077. }
  12078. /**
  12079. * Represents a gamepad
  12080. */
  12081. export class Gamepad {
  12082. /**
  12083. * The id of the gamepad
  12084. */
  12085. id: string;
  12086. /**
  12087. * The index of the gamepad
  12088. */
  12089. index: number;
  12090. /**
  12091. * The browser gamepad
  12092. */
  12093. browserGamepad: any;
  12094. /**
  12095. * Specifies what type of gamepad this represents
  12096. */
  12097. type: number;
  12098. private _leftStick;
  12099. private _rightStick;
  12100. /** @hidden */
  12101. _isConnected: boolean;
  12102. private _leftStickAxisX;
  12103. private _leftStickAxisY;
  12104. private _rightStickAxisX;
  12105. private _rightStickAxisY;
  12106. /**
  12107. * Triggered when the left control stick has been changed
  12108. */
  12109. private _onleftstickchanged;
  12110. /**
  12111. * Triggered when the right control stick has been changed
  12112. */
  12113. private _onrightstickchanged;
  12114. /**
  12115. * Represents a gamepad controller
  12116. */
  12117. static GAMEPAD: number;
  12118. /**
  12119. * Represents a generic controller
  12120. */
  12121. static GENERIC: number;
  12122. /**
  12123. * Represents an XBox controller
  12124. */
  12125. static XBOX: number;
  12126. /**
  12127. * Represents a pose-enabled controller
  12128. */
  12129. static POSE_ENABLED: number;
  12130. /**
  12131. * Represents an Dual Shock controller
  12132. */
  12133. static DUALSHOCK: number;
  12134. /**
  12135. * Specifies whether the left control stick should be Y-inverted
  12136. */
  12137. protected _invertLeftStickY: boolean;
  12138. /**
  12139. * Specifies if the gamepad has been connected
  12140. */
  12141. readonly isConnected: boolean;
  12142. /**
  12143. * Initializes the gamepad
  12144. * @param id The id of the gamepad
  12145. * @param index The index of the gamepad
  12146. * @param browserGamepad The browser gamepad
  12147. * @param leftStickX The x component of the left joystick
  12148. * @param leftStickY The y component of the left joystick
  12149. * @param rightStickX The x component of the right joystick
  12150. * @param rightStickY The y component of the right joystick
  12151. */
  12152. constructor(
  12153. /**
  12154. * The id of the gamepad
  12155. */
  12156. id: string,
  12157. /**
  12158. * The index of the gamepad
  12159. */
  12160. index: number,
  12161. /**
  12162. * The browser gamepad
  12163. */
  12164. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12165. /**
  12166. * Callback triggered when the left joystick has changed
  12167. * @param callback
  12168. */
  12169. onleftstickchanged(callback: (values: StickValues) => void): void;
  12170. /**
  12171. * Callback triggered when the right joystick has changed
  12172. * @param callback
  12173. */
  12174. onrightstickchanged(callback: (values: StickValues) => void): void;
  12175. /**
  12176. * Gets the left joystick
  12177. */
  12178. /**
  12179. * Sets the left joystick values
  12180. */
  12181. leftStick: StickValues;
  12182. /**
  12183. * Gets the right joystick
  12184. */
  12185. /**
  12186. * Sets the right joystick value
  12187. */
  12188. rightStick: StickValues;
  12189. /**
  12190. * Updates the gamepad joystick positions
  12191. */
  12192. update(): void;
  12193. /**
  12194. * Disposes the gamepad
  12195. */
  12196. dispose(): void;
  12197. }
  12198. /**
  12199. * Represents a generic gamepad
  12200. */
  12201. export class GenericPad extends Gamepad {
  12202. private _buttons;
  12203. private _onbuttondown;
  12204. private _onbuttonup;
  12205. /**
  12206. * Observable triggered when a button has been pressed
  12207. */
  12208. onButtonDownObservable: Observable<number>;
  12209. /**
  12210. * Observable triggered when a button has been released
  12211. */
  12212. onButtonUpObservable: Observable<number>;
  12213. /**
  12214. * Callback triggered when a button has been pressed
  12215. * @param callback Called when a button has been pressed
  12216. */
  12217. onbuttondown(callback: (buttonPressed: number) => void): void;
  12218. /**
  12219. * Callback triggered when a button has been released
  12220. * @param callback Called when a button has been released
  12221. */
  12222. onbuttonup(callback: (buttonReleased: number) => void): void;
  12223. /**
  12224. * Initializes the generic gamepad
  12225. * @param id The id of the generic gamepad
  12226. * @param index The index of the generic gamepad
  12227. * @param browserGamepad The browser gamepad
  12228. */
  12229. constructor(id: string, index: number, browserGamepad: any);
  12230. private _setButtonValue;
  12231. /**
  12232. * Updates the generic gamepad
  12233. */
  12234. update(): void;
  12235. /**
  12236. * Disposes the generic gamepad
  12237. */
  12238. dispose(): void;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. interface Engine {
  12243. /**
  12244. * Creates a raw texture
  12245. * @param data defines the data to store in the texture
  12246. * @param width defines the width of the texture
  12247. * @param height defines the height of the texture
  12248. * @param format defines the format of the data
  12249. * @param generateMipMaps defines if the engine should generate the mip levels
  12250. * @param invertY defines if data must be stored with Y axis inverted
  12251. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12252. * @param compression defines the compression used (null by default)
  12253. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12254. * @returns the raw texture inside an InternalTexture
  12255. */
  12256. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12257. /**
  12258. * Update a raw texture
  12259. * @param texture defines the texture to update
  12260. * @param data defines the data to store in the texture
  12261. * @param format defines the format of the data
  12262. * @param invertY defines if data must be stored with Y axis inverted
  12263. */
  12264. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12265. /**
  12266. * Update a raw texture
  12267. * @param texture defines the texture to update
  12268. * @param data defines the data to store in the texture
  12269. * @param format defines the format of the data
  12270. * @param invertY defines if data must be stored with Y axis inverted
  12271. * @param compression defines the compression used (null by default)
  12272. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12273. */
  12274. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12275. /**
  12276. * Creates a new raw cube texture
  12277. * @param data defines the array of data to use to create each face
  12278. * @param size defines the size of the textures
  12279. * @param format defines the format of the data
  12280. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12281. * @param generateMipMaps defines if the engine should generate the mip levels
  12282. * @param invertY defines if data must be stored with Y axis inverted
  12283. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12284. * @param compression defines the compression used (null by default)
  12285. * @returns the cube texture as an InternalTexture
  12286. */
  12287. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12288. /**
  12289. * Update a raw cube texture
  12290. * @param texture defines the texture to udpdate
  12291. * @param data defines the data to store
  12292. * @param format defines the data format
  12293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12294. * @param invertY defines if data must be stored with Y axis inverted
  12295. */
  12296. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12297. /**
  12298. * Update a raw cube texture
  12299. * @param texture defines the texture to udpdate
  12300. * @param data defines the data to store
  12301. * @param format defines the data format
  12302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12303. * @param invertY defines if data must be stored with Y axis inverted
  12304. * @param compression defines the compression used (null by default)
  12305. */
  12306. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12307. /**
  12308. * Update a raw cube texture
  12309. * @param texture defines the texture to udpdate
  12310. * @param data defines the data to store
  12311. * @param format defines the data format
  12312. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12313. * @param invertY defines if data must be stored with Y axis inverted
  12314. * @param compression defines the compression used (null by default)
  12315. * @param level defines which level of the texture to update
  12316. */
  12317. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12318. /**
  12319. * Creates a new raw cube texture from a specified url
  12320. * @param url defines the url where the data is located
  12321. * @param scene defines the current scene
  12322. * @param size defines the size of the textures
  12323. * @param format defines the format of the data
  12324. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12325. * @param noMipmap defines if the engine should avoid generating the mip levels
  12326. * @param callback defines a callback used to extract texture data from loaded data
  12327. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12328. * @param onLoad defines a callback called when texture is loaded
  12329. * @param onError defines a callback called if there is an error
  12330. * @returns the cube texture as an InternalTexture
  12331. */
  12332. 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;
  12333. /**
  12334. * Creates a new raw cube texture from a specified url
  12335. * @param url defines the url where the data is located
  12336. * @param scene defines the current scene
  12337. * @param size defines the size of the textures
  12338. * @param format defines the format of the data
  12339. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12340. * @param noMipmap defines if the engine should avoid generating the mip levels
  12341. * @param callback defines a callback used to extract texture data from loaded data
  12342. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12343. * @param onLoad defines a callback called when texture is loaded
  12344. * @param onError defines a callback called if there is an error
  12345. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12346. * @param invertY defines if data must be stored with Y axis inverted
  12347. * @returns the cube texture as an InternalTexture
  12348. */
  12349. 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;
  12350. /**
  12351. * Creates a new raw 3D texture
  12352. * @param data defines the data used to create the texture
  12353. * @param width defines the width of the texture
  12354. * @param height defines the height of the texture
  12355. * @param depth defines the depth of the texture
  12356. * @param format defines the format of the texture
  12357. * @param generateMipMaps defines if the engine must generate mip levels
  12358. * @param invertY defines if data must be stored with Y axis inverted
  12359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12360. * @param compression defines the compressed used (can be null)
  12361. * @param textureType defines the compressed used (can be null)
  12362. * @returns a new raw 3D texture (stored in an InternalTexture)
  12363. */
  12364. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12365. /**
  12366. * Update a raw 3D texture
  12367. * @param texture defines the texture to update
  12368. * @param data defines the data to store
  12369. * @param format defines the data format
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. */
  12372. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12373. /**
  12374. * Update a raw 3D texture
  12375. * @param texture defines the texture to update
  12376. * @param data defines the data to store
  12377. * @param format defines the data format
  12378. * @param invertY defines if data must be stored with Y axis inverted
  12379. * @param compression defines the used compression (can be null)
  12380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12381. */
  12382. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12383. }
  12384. }
  12385. declare module BABYLON {
  12386. /**
  12387. * Raw texture can help creating a texture directly from an array of data.
  12388. * This can be super useful if you either get the data from an uncompressed source or
  12389. * if you wish to create your texture pixel by pixel.
  12390. */
  12391. export class RawTexture extends Texture {
  12392. /**
  12393. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12394. */
  12395. format: number;
  12396. private _engine;
  12397. /**
  12398. * Instantiates a new RawTexture.
  12399. * Raw texture can help creating a texture directly from an array of data.
  12400. * This can be super useful if you either get the data from an uncompressed source or
  12401. * if you wish to create your texture pixel by pixel.
  12402. * @param data define the array of data to use to create the texture
  12403. * @param width define the width of the texture
  12404. * @param height define the height of the texture
  12405. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12406. * @param scene define the scene the texture belongs to
  12407. * @param generateMipMaps define whether mip maps should be generated or not
  12408. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12409. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12410. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12411. */
  12412. constructor(data: ArrayBufferView, width: number, height: number,
  12413. /**
  12414. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12415. */
  12416. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12417. /**
  12418. * Updates the texture underlying data.
  12419. * @param data Define the new data of the texture
  12420. */
  12421. update(data: ArrayBufferView): void;
  12422. /**
  12423. * Creates a luminance texture from some data.
  12424. * @param data Define the texture data
  12425. * @param width Define the width of the texture
  12426. * @param height Define the height of the texture
  12427. * @param scene Define the scene the texture belongs to
  12428. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12429. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12430. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12431. * @returns the luminance texture
  12432. */
  12433. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12434. /**
  12435. * Creates a luminance alpha texture from some data.
  12436. * @param data Define the texture data
  12437. * @param width Define the width of the texture
  12438. * @param height Define the height of the texture
  12439. * @param scene Define the scene the texture belongs to
  12440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12443. * @returns the luminance alpha texture
  12444. */
  12445. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12446. /**
  12447. * Creates an alpha texture from some data.
  12448. * @param data Define the texture data
  12449. * @param width Define the width of the texture
  12450. * @param height Define the height of the texture
  12451. * @param scene Define the scene the texture belongs to
  12452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12455. * @returns the alpha texture
  12456. */
  12457. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12458. /**
  12459. * Creates a RGB texture from some data.
  12460. * @param data Define the texture data
  12461. * @param width Define the width of the texture
  12462. * @param height Define the height of the texture
  12463. * @param scene Define the scene the texture belongs to
  12464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12467. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12468. * @returns the RGB alpha texture
  12469. */
  12470. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12471. /**
  12472. * Creates a RGBA texture from some data.
  12473. * @param data Define the texture data
  12474. * @param width Define the width of the texture
  12475. * @param height Define the height of the texture
  12476. * @param scene Define the scene the texture belongs to
  12477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12481. * @returns the RGBA texture
  12482. */
  12483. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12484. /**
  12485. * Creates a R texture from some data.
  12486. * @param data Define the texture data
  12487. * @param width Define the width of the texture
  12488. * @param height Define the height of the texture
  12489. * @param scene Define the scene the texture belongs to
  12490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12494. * @returns the R texture
  12495. */
  12496. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12497. }
  12498. }
  12499. declare module BABYLON {
  12500. /**
  12501. * Interface for the size containing width and height
  12502. */
  12503. export interface ISize {
  12504. /**
  12505. * Width
  12506. */
  12507. width: number;
  12508. /**
  12509. * Heighht
  12510. */
  12511. height: number;
  12512. }
  12513. /**
  12514. * Size containing widht and height
  12515. */
  12516. export class Size implements ISize {
  12517. /**
  12518. * Width
  12519. */
  12520. width: number;
  12521. /**
  12522. * Height
  12523. */
  12524. height: number;
  12525. /**
  12526. * Creates a Size object from the given width and height (floats).
  12527. * @param width width of the new size
  12528. * @param height height of the new size
  12529. */
  12530. constructor(width: number, height: number);
  12531. /**
  12532. * Returns a string with the Size width and height
  12533. * @returns a string with the Size width and height
  12534. */
  12535. toString(): string;
  12536. /**
  12537. * "Size"
  12538. * @returns the string "Size"
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Returns the Size hash code.
  12543. * @returns a hash code for a unique width and height
  12544. */
  12545. getHashCode(): number;
  12546. /**
  12547. * Updates the current size from the given one.
  12548. * @param src the given size
  12549. */
  12550. copyFrom(src: Size): void;
  12551. /**
  12552. * Updates in place the current Size from the given floats.
  12553. * @param width width of the new size
  12554. * @param height height of the new size
  12555. * @returns the updated Size.
  12556. */
  12557. copyFromFloats(width: number, height: number): Size;
  12558. /**
  12559. * Updates in place the current Size from the given floats.
  12560. * @param width width to set
  12561. * @param height height to set
  12562. * @returns the updated Size.
  12563. */
  12564. set(width: number, height: number): Size;
  12565. /**
  12566. * Multiplies the width and height by numbers
  12567. * @param w factor to multiple the width by
  12568. * @param h factor to multiple the height by
  12569. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12570. */
  12571. multiplyByFloats(w: number, h: number): Size;
  12572. /**
  12573. * Clones the size
  12574. * @returns a new Size copied from the given one.
  12575. */
  12576. clone(): Size;
  12577. /**
  12578. * True if the current Size and the given one width and height are strictly equal.
  12579. * @param other the other size to compare against
  12580. * @returns True if the current Size and the given one width and height are strictly equal.
  12581. */
  12582. equals(other: Size): boolean;
  12583. /**
  12584. * The surface of the Size : width * height (float).
  12585. */
  12586. readonly surface: number;
  12587. /**
  12588. * Create a new size of zero
  12589. * @returns a new Size set to (0.0, 0.0)
  12590. */
  12591. static Zero(): Size;
  12592. /**
  12593. * Sums the width and height of two sizes
  12594. * @param otherSize size to add to this size
  12595. * @returns a new Size set as the addition result of the current Size and the given one.
  12596. */
  12597. add(otherSize: Size): Size;
  12598. /**
  12599. * Subtracts the width and height of two
  12600. * @param otherSize size to subtract to this size
  12601. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12602. */
  12603. subtract(otherSize: Size): Size;
  12604. /**
  12605. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12606. * @param start starting size to lerp between
  12607. * @param end end size to lerp between
  12608. * @param amount amount to lerp between the start and end values
  12609. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12610. */
  12611. static Lerp(start: Size, end: Size, amount: number): Size;
  12612. }
  12613. }
  12614. declare module BABYLON {
  12615. /**
  12616. * Defines a runtime animation
  12617. */
  12618. export class RuntimeAnimation {
  12619. private _events;
  12620. /**
  12621. * The current frame of the runtime animation
  12622. */
  12623. private _currentFrame;
  12624. /**
  12625. * The animation used by the runtime animation
  12626. */
  12627. private _animation;
  12628. /**
  12629. * The target of the runtime animation
  12630. */
  12631. private _target;
  12632. /**
  12633. * The initiating animatable
  12634. */
  12635. private _host;
  12636. /**
  12637. * The original value of the runtime animation
  12638. */
  12639. private _originalValue;
  12640. /**
  12641. * The original blend value of the runtime animation
  12642. */
  12643. private _originalBlendValue;
  12644. /**
  12645. * The offsets cache of the runtime animation
  12646. */
  12647. private _offsetsCache;
  12648. /**
  12649. * The high limits cache of the runtime animation
  12650. */
  12651. private _highLimitsCache;
  12652. /**
  12653. * Specifies if the runtime animation has been stopped
  12654. */
  12655. private _stopped;
  12656. /**
  12657. * The blending factor of the runtime animation
  12658. */
  12659. private _blendingFactor;
  12660. /**
  12661. * The BabylonJS scene
  12662. */
  12663. private _scene;
  12664. /**
  12665. * The current value of the runtime animation
  12666. */
  12667. private _currentValue;
  12668. /** @hidden */
  12669. _animationState: _IAnimationState;
  12670. /**
  12671. * The active target of the runtime animation
  12672. */
  12673. private _activeTargets;
  12674. private _currentActiveTarget;
  12675. private _directTarget;
  12676. /**
  12677. * The target path of the runtime animation
  12678. */
  12679. private _targetPath;
  12680. /**
  12681. * The weight of the runtime animation
  12682. */
  12683. private _weight;
  12684. /**
  12685. * The ratio offset of the runtime animation
  12686. */
  12687. private _ratioOffset;
  12688. /**
  12689. * The previous delay of the runtime animation
  12690. */
  12691. private _previousDelay;
  12692. /**
  12693. * The previous ratio of the runtime animation
  12694. */
  12695. private _previousRatio;
  12696. private _enableBlending;
  12697. private _keys;
  12698. private _minFrame;
  12699. private _maxFrame;
  12700. private _minValue;
  12701. private _maxValue;
  12702. private _targetIsArray;
  12703. /**
  12704. * Gets the current frame of the runtime animation
  12705. */
  12706. readonly currentFrame: number;
  12707. /**
  12708. * Gets the weight of the runtime animation
  12709. */
  12710. readonly weight: number;
  12711. /**
  12712. * Gets the current value of the runtime animation
  12713. */
  12714. readonly currentValue: any;
  12715. /**
  12716. * Gets the target path of the runtime animation
  12717. */
  12718. readonly targetPath: string;
  12719. /**
  12720. * Gets the actual target of the runtime animation
  12721. */
  12722. readonly target: any;
  12723. /** @hidden */
  12724. _onLoop: () => void;
  12725. /**
  12726. * Create a new RuntimeAnimation object
  12727. * @param target defines the target of the animation
  12728. * @param animation defines the source animation object
  12729. * @param scene defines the hosting scene
  12730. * @param host defines the initiating Animatable
  12731. */
  12732. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12733. private _preparePath;
  12734. /**
  12735. * Gets the animation from the runtime animation
  12736. */
  12737. readonly animation: Animation;
  12738. /**
  12739. * Resets the runtime animation to the beginning
  12740. * @param restoreOriginal defines whether to restore the target property to the original value
  12741. */
  12742. reset(restoreOriginal?: boolean): void;
  12743. /**
  12744. * Specifies if the runtime animation is stopped
  12745. * @returns Boolean specifying if the runtime animation is stopped
  12746. */
  12747. isStopped(): boolean;
  12748. /**
  12749. * Disposes of the runtime animation
  12750. */
  12751. dispose(): void;
  12752. /**
  12753. * Apply the interpolated value to the target
  12754. * @param currentValue defines the value computed by the animation
  12755. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12756. */
  12757. setValue(currentValue: any, weight: number): void;
  12758. private _getOriginalValues;
  12759. private _setValue;
  12760. /**
  12761. * Gets the loop pmode of the runtime animation
  12762. * @returns Loop Mode
  12763. */
  12764. private _getCorrectLoopMode;
  12765. /**
  12766. * Move the current animation to a given frame
  12767. * @param frame defines the frame to move to
  12768. */
  12769. goToFrame(frame: number): void;
  12770. /**
  12771. * @hidden Internal use only
  12772. */
  12773. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12774. /**
  12775. * Execute the current animation
  12776. * @param delay defines the delay to add to the current frame
  12777. * @param from defines the lower bound of the animation range
  12778. * @param to defines the upper bound of the animation range
  12779. * @param loop defines if the current animation must loop
  12780. * @param speedRatio defines the current speed ratio
  12781. * @param weight defines the weight of the animation (default is -1 so no weight)
  12782. * @param onLoop optional callback called when animation loops
  12783. * @returns a boolean indicating if the animation is running
  12784. */
  12785. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12786. }
  12787. }
  12788. declare module BABYLON {
  12789. /**
  12790. * Class used to store an actual running animation
  12791. */
  12792. export class Animatable {
  12793. /** defines the target object */
  12794. target: any;
  12795. /** defines the starting frame number (default is 0) */
  12796. fromFrame: number;
  12797. /** defines the ending frame number (default is 100) */
  12798. toFrame: number;
  12799. /** defines if the animation must loop (default is false) */
  12800. loopAnimation: boolean;
  12801. /** defines a callback to call when animation ends if it is not looping */
  12802. onAnimationEnd?: (() => void) | null | undefined;
  12803. /** defines a callback to call when animation loops */
  12804. onAnimationLoop?: (() => void) | null | undefined;
  12805. private _localDelayOffset;
  12806. private _pausedDelay;
  12807. private _runtimeAnimations;
  12808. private _paused;
  12809. private _scene;
  12810. private _speedRatio;
  12811. private _weight;
  12812. private _syncRoot;
  12813. /**
  12814. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12815. * This will only apply for non looping animation (default is true)
  12816. */
  12817. disposeOnEnd: boolean;
  12818. /**
  12819. * Gets a boolean indicating if the animation has started
  12820. */
  12821. animationStarted: boolean;
  12822. /**
  12823. * Observer raised when the animation ends
  12824. */
  12825. onAnimationEndObservable: Observable<Animatable>;
  12826. /**
  12827. * Observer raised when the animation loops
  12828. */
  12829. onAnimationLoopObservable: Observable<Animatable>;
  12830. /**
  12831. * Gets the root Animatable used to synchronize and normalize animations
  12832. */
  12833. readonly syncRoot: Nullable<Animatable>;
  12834. /**
  12835. * Gets the current frame of the first RuntimeAnimation
  12836. * Used to synchronize Animatables
  12837. */
  12838. readonly masterFrame: number;
  12839. /**
  12840. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12841. */
  12842. weight: number;
  12843. /**
  12844. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12845. */
  12846. speedRatio: number;
  12847. /**
  12848. * Creates a new Animatable
  12849. * @param scene defines the hosting scene
  12850. * @param target defines the target object
  12851. * @param fromFrame defines the starting frame number (default is 0)
  12852. * @param toFrame defines the ending frame number (default is 100)
  12853. * @param loopAnimation defines if the animation must loop (default is false)
  12854. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12855. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12856. * @param animations defines a group of animation to add to the new Animatable
  12857. * @param onAnimationLoop defines a callback to call when animation loops
  12858. */
  12859. constructor(scene: Scene,
  12860. /** defines the target object */
  12861. target: any,
  12862. /** defines the starting frame number (default is 0) */
  12863. fromFrame?: number,
  12864. /** defines the ending frame number (default is 100) */
  12865. toFrame?: number,
  12866. /** defines if the animation must loop (default is false) */
  12867. loopAnimation?: boolean, speedRatio?: number,
  12868. /** defines a callback to call when animation ends if it is not looping */
  12869. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12870. /** defines a callback to call when animation loops */
  12871. onAnimationLoop?: (() => void) | null | undefined);
  12872. /**
  12873. * Synchronize and normalize current Animatable with a source Animatable
  12874. * This is useful when using animation weights and when animations are not of the same length
  12875. * @param root defines the root Animatable to synchronize with
  12876. * @returns the current Animatable
  12877. */
  12878. syncWith(root: Animatable): Animatable;
  12879. /**
  12880. * Gets the list of runtime animations
  12881. * @returns an array of RuntimeAnimation
  12882. */
  12883. getAnimations(): RuntimeAnimation[];
  12884. /**
  12885. * Adds more animations to the current animatable
  12886. * @param target defines the target of the animations
  12887. * @param animations defines the new animations to add
  12888. */
  12889. appendAnimations(target: any, animations: Animation[]): void;
  12890. /**
  12891. * Gets the source animation for a specific property
  12892. * @param property defines the propertyu to look for
  12893. * @returns null or the source animation for the given property
  12894. */
  12895. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12896. /**
  12897. * Gets the runtime animation for a specific property
  12898. * @param property defines the propertyu to look for
  12899. * @returns null or the runtime animation for the given property
  12900. */
  12901. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12902. /**
  12903. * Resets the animatable to its original state
  12904. */
  12905. reset(): void;
  12906. /**
  12907. * Allows the animatable to blend with current running animations
  12908. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12909. * @param blendingSpeed defines the blending speed to use
  12910. */
  12911. enableBlending(blendingSpeed: number): void;
  12912. /**
  12913. * Disable animation blending
  12914. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12915. */
  12916. disableBlending(): void;
  12917. /**
  12918. * Jump directly to a given frame
  12919. * @param frame defines the frame to jump to
  12920. */
  12921. goToFrame(frame: number): void;
  12922. /**
  12923. * Pause the animation
  12924. */
  12925. pause(): void;
  12926. /**
  12927. * Restart the animation
  12928. */
  12929. restart(): void;
  12930. private _raiseOnAnimationEnd;
  12931. /**
  12932. * Stop and delete the current animation
  12933. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12934. * @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)
  12935. */
  12936. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12937. /**
  12938. * Wait asynchronously for the animation to end
  12939. * @returns a promise which will be fullfilled when the animation ends
  12940. */
  12941. waitAsync(): Promise<Animatable>;
  12942. /** @hidden */
  12943. _animate(delay: number): boolean;
  12944. }
  12945. interface Scene {
  12946. /** @hidden */
  12947. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12948. /** @hidden */
  12949. _processLateAnimationBindingsForMatrices(holder: {
  12950. totalWeight: number;
  12951. animations: RuntimeAnimation[];
  12952. originalValue: Matrix;
  12953. }): any;
  12954. /** @hidden */
  12955. _processLateAnimationBindingsForQuaternions(holder: {
  12956. totalWeight: number;
  12957. animations: RuntimeAnimation[];
  12958. originalValue: Quaternion;
  12959. }, refQuaternion: Quaternion): Quaternion;
  12960. /** @hidden */
  12961. _processLateAnimationBindings(): void;
  12962. /**
  12963. * Will start the animation sequence of a given target
  12964. * @param target defines the target
  12965. * @param from defines from which frame should animation start
  12966. * @param to defines until which frame should animation run.
  12967. * @param weight defines the weight to apply to the animation (1.0 by default)
  12968. * @param loop defines if the animation loops
  12969. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12970. * @param onAnimationEnd defines the function to be executed when the animation ends
  12971. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12972. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12973. * @param onAnimationLoop defines the callback to call when an animation loops
  12974. * @returns the animatable object created for this animation
  12975. */
  12976. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12977. /**
  12978. * Will start the animation sequence of a given target
  12979. * @param target defines the target
  12980. * @param from defines from which frame should animation start
  12981. * @param to defines until which frame should animation run.
  12982. * @param loop defines if the animation loops
  12983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12984. * @param onAnimationEnd defines the function to be executed when the animation ends
  12985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12986. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12987. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12988. * @param onAnimationLoop defines the callback to call when an animation loops
  12989. * @returns the animatable object created for this animation
  12990. */
  12991. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12992. /**
  12993. * Will start the animation sequence of a given target and its hierarchy
  12994. * @param target defines the target
  12995. * @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.
  12996. * @param from defines from which frame should animation start
  12997. * @param to defines until which frame should animation run.
  12998. * @param loop defines if the animation loops
  12999. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13000. * @param onAnimationEnd defines the function to be executed when the animation ends
  13001. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13002. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13003. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13004. * @param onAnimationLoop defines the callback to call when an animation loops
  13005. * @returns the list of created animatables
  13006. */
  13007. 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[];
  13008. /**
  13009. * Begin a new animation on a given node
  13010. * @param target defines the target where the animation will take place
  13011. * @param animations defines the list of animations to start
  13012. * @param from defines the initial value
  13013. * @param to defines the final value
  13014. * @param loop defines if you want animation to loop (off by default)
  13015. * @param speedRatio defines the speed ratio to apply to all animations
  13016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13017. * @param onAnimationLoop defines the callback to call when an animation loops
  13018. * @returns the list of created animatables
  13019. */
  13020. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13021. /**
  13022. * Begin a new animation on a given node and its hierarchy
  13023. * @param target defines the root node where the animation will take place
  13024. * @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.
  13025. * @param animations defines the list of animations to start
  13026. * @param from defines the initial value
  13027. * @param to defines the final value
  13028. * @param loop defines if you want animation to loop (off by default)
  13029. * @param speedRatio defines the speed ratio to apply to all animations
  13030. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13031. * @param onAnimationLoop defines the callback to call when an animation loops
  13032. * @returns the list of animatables created for all nodes
  13033. */
  13034. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13035. /**
  13036. * Gets the animatable associated with a specific target
  13037. * @param target defines the target of the animatable
  13038. * @returns the required animatable if found
  13039. */
  13040. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13041. /**
  13042. * Gets all animatables associated with a given target
  13043. * @param target defines the target to look animatables for
  13044. * @returns an array of Animatables
  13045. */
  13046. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13047. /**
  13048. * Stops and removes all animations that have been applied to the scene
  13049. */
  13050. stopAllAnimations(): void;
  13051. }
  13052. interface Bone {
  13053. /**
  13054. * Copy an animation range from another bone
  13055. * @param source defines the source bone
  13056. * @param rangeName defines the range name to copy
  13057. * @param frameOffset defines the frame offset
  13058. * @param rescaleAsRequired defines if rescaling must be applied if required
  13059. * @param skelDimensionsRatio defines the scaling ratio
  13060. * @returns true if operation was successful
  13061. */
  13062. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13063. }
  13064. }
  13065. declare module BABYLON {
  13066. /**
  13067. * Class used to override all child animations of a given target
  13068. */
  13069. export class AnimationPropertiesOverride {
  13070. /**
  13071. * Gets or sets a value indicating if animation blending must be used
  13072. */
  13073. enableBlending: boolean;
  13074. /**
  13075. * Gets or sets the blending speed to use when enableBlending is true
  13076. */
  13077. blendingSpeed: number;
  13078. /**
  13079. * Gets or sets the default loop mode to use
  13080. */
  13081. loopMode: number;
  13082. }
  13083. }
  13084. declare module BABYLON {
  13085. /**
  13086. * Class used to handle skinning animations
  13087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13088. */
  13089. export class Skeleton implements IAnimatable {
  13090. /** defines the skeleton name */
  13091. name: string;
  13092. /** defines the skeleton Id */
  13093. id: string;
  13094. /**
  13095. * Defines the list of child bones
  13096. */
  13097. bones: Bone[];
  13098. /**
  13099. * Defines an estimate of the dimension of the skeleton at rest
  13100. */
  13101. dimensionsAtRest: Vector3;
  13102. /**
  13103. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13104. */
  13105. needInitialSkinMatrix: boolean;
  13106. /**
  13107. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13108. */
  13109. overrideMesh: Nullable<AbstractMesh>;
  13110. /**
  13111. * Gets the list of animations attached to this skeleton
  13112. */
  13113. animations: Array<Animation>;
  13114. private _scene;
  13115. private _isDirty;
  13116. private _transformMatrices;
  13117. private _transformMatrixTexture;
  13118. private _meshesWithPoseMatrix;
  13119. private _animatables;
  13120. private _identity;
  13121. private _synchronizedWithMesh;
  13122. private _ranges;
  13123. private _lastAbsoluteTransformsUpdateId;
  13124. private _canUseTextureForBones;
  13125. private _uniqueId;
  13126. /** @hidden */
  13127. _numBonesWithLinkedTransformNode: number;
  13128. /** @hidden */
  13129. _hasWaitingData: Nullable<boolean>;
  13130. /**
  13131. * Specifies if the skeleton should be serialized
  13132. */
  13133. doNotSerialize: boolean;
  13134. private _useTextureToStoreBoneMatrices;
  13135. /**
  13136. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13137. * Please note that this option is not available if the hardware does not support it
  13138. */
  13139. useTextureToStoreBoneMatrices: boolean;
  13140. private _animationPropertiesOverride;
  13141. /**
  13142. * Gets or sets the animation properties override
  13143. */
  13144. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13145. /**
  13146. * List of inspectable custom properties (used by the Inspector)
  13147. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13148. */
  13149. inspectableCustomProperties: IInspectable[];
  13150. /**
  13151. * An observable triggered before computing the skeleton's matrices
  13152. */
  13153. onBeforeComputeObservable: Observable<Skeleton>;
  13154. /**
  13155. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13156. */
  13157. readonly isUsingTextureForMatrices: boolean;
  13158. /**
  13159. * Gets the unique ID of this skeleton
  13160. */
  13161. readonly uniqueId: number;
  13162. /**
  13163. * Creates a new skeleton
  13164. * @param name defines the skeleton name
  13165. * @param id defines the skeleton Id
  13166. * @param scene defines the hosting scene
  13167. */
  13168. constructor(
  13169. /** defines the skeleton name */
  13170. name: string,
  13171. /** defines the skeleton Id */
  13172. id: string, scene: Scene);
  13173. /**
  13174. * Gets the current object class name.
  13175. * @return the class name
  13176. */
  13177. getClassName(): string;
  13178. /**
  13179. * Returns an array containing the root bones
  13180. * @returns an array containing the root bones
  13181. */
  13182. getChildren(): Array<Bone>;
  13183. /**
  13184. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13185. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13186. * @returns a Float32Array containing matrices data
  13187. */
  13188. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13189. /**
  13190. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13191. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13192. * @returns a raw texture containing the data
  13193. */
  13194. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13195. /**
  13196. * Gets the current hosting scene
  13197. * @returns a scene object
  13198. */
  13199. getScene(): Scene;
  13200. /**
  13201. * Gets a string representing the current skeleton data
  13202. * @param fullDetails defines a boolean indicating if we want a verbose version
  13203. * @returns a string representing the current skeleton data
  13204. */
  13205. toString(fullDetails?: boolean): string;
  13206. /**
  13207. * Get bone's index searching by name
  13208. * @param name defines bone's name to search for
  13209. * @return the indice of the bone. Returns -1 if not found
  13210. */
  13211. getBoneIndexByName(name: string): number;
  13212. /**
  13213. * Creater a new animation range
  13214. * @param name defines the name of the range
  13215. * @param from defines the start key
  13216. * @param to defines the end key
  13217. */
  13218. createAnimationRange(name: string, from: number, to: number): void;
  13219. /**
  13220. * Delete a specific animation range
  13221. * @param name defines the name of the range
  13222. * @param deleteFrames defines if frames must be removed as well
  13223. */
  13224. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13225. /**
  13226. * Gets a specific animation range
  13227. * @param name defines the name of the range to look for
  13228. * @returns the requested animation range or null if not found
  13229. */
  13230. getAnimationRange(name: string): Nullable<AnimationRange>;
  13231. /**
  13232. * Gets the list of all animation ranges defined on this skeleton
  13233. * @returns an array
  13234. */
  13235. getAnimationRanges(): Nullable<AnimationRange>[];
  13236. /**
  13237. * Copy animation range from a source skeleton.
  13238. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13239. * @param source defines the source skeleton
  13240. * @param name defines the name of the range to copy
  13241. * @param rescaleAsRequired defines if rescaling must be applied if required
  13242. * @returns true if operation was successful
  13243. */
  13244. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13245. /**
  13246. * Forces the skeleton to go to rest pose
  13247. */
  13248. returnToRest(): void;
  13249. private _getHighestAnimationFrame;
  13250. /**
  13251. * Begin a specific animation range
  13252. * @param name defines the name of the range to start
  13253. * @param loop defines if looping must be turned on (false by default)
  13254. * @param speedRatio defines the speed ratio to apply (1 by default)
  13255. * @param onAnimationEnd defines a callback which will be called when animation will end
  13256. * @returns a new animatable
  13257. */
  13258. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13259. /** @hidden */
  13260. _markAsDirty(): void;
  13261. /** @hidden */
  13262. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13263. /** @hidden */
  13264. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13265. private _computeTransformMatrices;
  13266. /**
  13267. * Build all resources required to render a skeleton
  13268. */
  13269. prepare(): void;
  13270. /**
  13271. * Gets the list of animatables currently running for this skeleton
  13272. * @returns an array of animatables
  13273. */
  13274. getAnimatables(): IAnimatable[];
  13275. /**
  13276. * Clone the current skeleton
  13277. * @param name defines the name of the new skeleton
  13278. * @param id defines the id of the new skeleton
  13279. * @returns the new skeleton
  13280. */
  13281. clone(name: string, id: string): Skeleton;
  13282. /**
  13283. * Enable animation blending for this skeleton
  13284. * @param blendingSpeed defines the blending speed to apply
  13285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13286. */
  13287. enableBlending(blendingSpeed?: number): void;
  13288. /**
  13289. * Releases all resources associated with the current skeleton
  13290. */
  13291. dispose(): void;
  13292. /**
  13293. * Serialize the skeleton in a JSON object
  13294. * @returns a JSON object
  13295. */
  13296. serialize(): any;
  13297. /**
  13298. * Creates a new skeleton from serialized data
  13299. * @param parsedSkeleton defines the serialized data
  13300. * @param scene defines the hosting scene
  13301. * @returns a new skeleton
  13302. */
  13303. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13304. /**
  13305. * Compute all node absolute transforms
  13306. * @param forceUpdate defines if computation must be done even if cache is up to date
  13307. */
  13308. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13309. /**
  13310. * Gets the root pose matrix
  13311. * @returns a matrix
  13312. */
  13313. getPoseMatrix(): Nullable<Matrix>;
  13314. /**
  13315. * Sorts bones per internal index
  13316. */
  13317. sortBones(): void;
  13318. private _sortBones;
  13319. }
  13320. }
  13321. declare module BABYLON {
  13322. /**
  13323. * Class used to store bone information
  13324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13325. */
  13326. export class Bone extends Node {
  13327. /**
  13328. * defines the bone name
  13329. */
  13330. name: string;
  13331. private static _tmpVecs;
  13332. private static _tmpQuat;
  13333. private static _tmpMats;
  13334. /**
  13335. * Gets the list of child bones
  13336. */
  13337. children: Bone[];
  13338. /** Gets the animations associated with this bone */
  13339. animations: Animation[];
  13340. /**
  13341. * Gets or sets bone length
  13342. */
  13343. length: number;
  13344. /**
  13345. * @hidden Internal only
  13346. * Set this value to map this bone to a different index in the transform matrices
  13347. * Set this value to -1 to exclude the bone from the transform matrices
  13348. */
  13349. _index: Nullable<number>;
  13350. private _skeleton;
  13351. private _localMatrix;
  13352. private _restPose;
  13353. private _baseMatrix;
  13354. private _absoluteTransform;
  13355. private _invertedAbsoluteTransform;
  13356. private _parent;
  13357. private _scalingDeterminant;
  13358. private _worldTransform;
  13359. private _localScaling;
  13360. private _localRotation;
  13361. private _localPosition;
  13362. private _needToDecompose;
  13363. private _needToCompose;
  13364. /** @hidden */
  13365. _linkedTransformNode: Nullable<TransformNode>;
  13366. /** @hidden */
  13367. _waitingTransformNodeId: Nullable<string>;
  13368. /** @hidden */
  13369. /** @hidden */
  13370. _matrix: Matrix;
  13371. /**
  13372. * Create a new bone
  13373. * @param name defines the bone name
  13374. * @param skeleton defines the parent skeleton
  13375. * @param parentBone defines the parent (can be null if the bone is the root)
  13376. * @param localMatrix defines the local matrix
  13377. * @param restPose defines the rest pose matrix
  13378. * @param baseMatrix defines the base matrix
  13379. * @param index defines index of the bone in the hiearchy
  13380. */
  13381. constructor(
  13382. /**
  13383. * defines the bone name
  13384. */
  13385. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13386. /**
  13387. * Gets the current object class name.
  13388. * @return the class name
  13389. */
  13390. getClassName(): string;
  13391. /**
  13392. * Gets the parent skeleton
  13393. * @returns a skeleton
  13394. */
  13395. getSkeleton(): Skeleton;
  13396. /**
  13397. * Gets parent bone
  13398. * @returns a bone or null if the bone is the root of the bone hierarchy
  13399. */
  13400. getParent(): Nullable<Bone>;
  13401. /**
  13402. * Returns an array containing the root bones
  13403. * @returns an array containing the root bones
  13404. */
  13405. getChildren(): Array<Bone>;
  13406. /**
  13407. * Sets the parent bone
  13408. * @param parent defines the parent (can be null if the bone is the root)
  13409. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13410. */
  13411. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13412. /**
  13413. * Gets the local matrix
  13414. * @returns a matrix
  13415. */
  13416. getLocalMatrix(): Matrix;
  13417. /**
  13418. * Gets the base matrix (initial matrix which remains unchanged)
  13419. * @returns a matrix
  13420. */
  13421. getBaseMatrix(): Matrix;
  13422. /**
  13423. * Gets the rest pose matrix
  13424. * @returns a matrix
  13425. */
  13426. getRestPose(): Matrix;
  13427. /**
  13428. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13429. */
  13430. getWorldMatrix(): Matrix;
  13431. /**
  13432. * Sets the local matrix to rest pose matrix
  13433. */
  13434. returnToRest(): void;
  13435. /**
  13436. * Gets the inverse of the absolute transform matrix.
  13437. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13438. * @returns a matrix
  13439. */
  13440. getInvertedAbsoluteTransform(): Matrix;
  13441. /**
  13442. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13443. * @returns a matrix
  13444. */
  13445. getAbsoluteTransform(): Matrix;
  13446. /**
  13447. * Links with the given transform node.
  13448. * The local matrix of this bone is copied from the transform node every frame.
  13449. * @param transformNode defines the transform node to link to
  13450. */
  13451. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13452. /**
  13453. * Gets the node used to drive the bone's transformation
  13454. * @returns a transform node or null
  13455. */
  13456. getTransformNode(): Nullable<TransformNode>;
  13457. /** Gets or sets current position (in local space) */
  13458. position: Vector3;
  13459. /** Gets or sets current rotation (in local space) */
  13460. rotation: Vector3;
  13461. /** Gets or sets current rotation quaternion (in local space) */
  13462. rotationQuaternion: Quaternion;
  13463. /** Gets or sets current scaling (in local space) */
  13464. scaling: Vector3;
  13465. /**
  13466. * Gets the animation properties override
  13467. */
  13468. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13469. private _decompose;
  13470. private _compose;
  13471. /**
  13472. * Update the base and local matrices
  13473. * @param matrix defines the new base or local matrix
  13474. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13475. * @param updateLocalMatrix defines if the local matrix should be updated
  13476. */
  13477. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13478. /** @hidden */
  13479. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13480. /**
  13481. * Flag the bone as dirty (Forcing it to update everything)
  13482. */
  13483. markAsDirty(): void;
  13484. /** @hidden */
  13485. _markAsDirtyAndCompose(): void;
  13486. private _markAsDirtyAndDecompose;
  13487. /**
  13488. * Translate the bone in local or world space
  13489. * @param vec The amount to translate the bone
  13490. * @param space The space that the translation is in
  13491. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13492. */
  13493. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13494. /**
  13495. * Set the postion of the bone in local or world space
  13496. * @param position The position to set the bone
  13497. * @param space The space that the position is in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. */
  13500. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13501. /**
  13502. * Set the absolute position of the bone (world space)
  13503. * @param position The position to set the bone
  13504. * @param mesh The mesh that this bone is attached to
  13505. */
  13506. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13507. /**
  13508. * Scale the bone on the x, y and z axes (in local space)
  13509. * @param x The amount to scale the bone on the x axis
  13510. * @param y The amount to scale the bone on the y axis
  13511. * @param z The amount to scale the bone on the z axis
  13512. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13513. */
  13514. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13515. /**
  13516. * Set the bone scaling in local space
  13517. * @param scale defines the scaling vector
  13518. */
  13519. setScale(scale: Vector3): void;
  13520. /**
  13521. * Gets the current scaling in local space
  13522. * @returns the current scaling vector
  13523. */
  13524. getScale(): Vector3;
  13525. /**
  13526. * Gets the current scaling in local space and stores it in a target vector
  13527. * @param result defines the target vector
  13528. */
  13529. getScaleToRef(result: Vector3): void;
  13530. /**
  13531. * Set the yaw, pitch, and roll of the bone in local or world space
  13532. * @param yaw The rotation of the bone on the y axis
  13533. * @param pitch The rotation of the bone on the x axis
  13534. * @param roll The rotation of the bone on the z axis
  13535. * @param space The space that the axes of rotation are in
  13536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13537. */
  13538. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13539. /**
  13540. * Add a rotation to the bone on an axis in local or world space
  13541. * @param axis The axis to rotate the bone on
  13542. * @param amount The amount to rotate the bone
  13543. * @param space The space that the axis is in
  13544. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13545. */
  13546. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13547. /**
  13548. * Set the rotation of the bone to a particular axis angle in local or world space
  13549. * @param axis The axis to rotate the bone on
  13550. * @param angle The angle that the bone should be rotated to
  13551. * @param space The space that the axis is in
  13552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13553. */
  13554. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13555. /**
  13556. * Set the euler rotation of the bone in local of world space
  13557. * @param rotation The euler rotation that the bone should be set to
  13558. * @param space The space that the rotation is in
  13559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13560. */
  13561. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13562. /**
  13563. * Set the quaternion rotation of the bone in local of world space
  13564. * @param quat The quaternion rotation that the bone should be set to
  13565. * @param space The space that the rotation is in
  13566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13567. */
  13568. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13569. /**
  13570. * Set the rotation matrix of the bone in local of world space
  13571. * @param rotMat The rotation matrix that the bone should be set to
  13572. * @param space The space that the rotation is in
  13573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13574. */
  13575. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13576. private _rotateWithMatrix;
  13577. private _getNegativeRotationToRef;
  13578. /**
  13579. * Get the position of the bone in local or world space
  13580. * @param space The space that the returned position is in
  13581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13582. * @returns The position of the bone
  13583. */
  13584. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13585. /**
  13586. * Copy the position of the bone to a vector3 in local or world space
  13587. * @param space The space that the returned position is in
  13588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13589. * @param result The vector3 to copy the position to
  13590. */
  13591. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13592. /**
  13593. * Get the absolute position of the bone (world space)
  13594. * @param mesh The mesh that this bone is attached to
  13595. * @returns The absolute position of the bone
  13596. */
  13597. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13598. /**
  13599. * Copy the absolute position of the bone (world space) to the result param
  13600. * @param mesh The mesh that this bone is attached to
  13601. * @param result The vector3 to copy the absolute position to
  13602. */
  13603. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13604. /**
  13605. * Compute the absolute transforms of this bone and its children
  13606. */
  13607. computeAbsoluteTransforms(): void;
  13608. /**
  13609. * Get the world direction from an axis that is in the local space of the bone
  13610. * @param localAxis The local direction that is used to compute the world direction
  13611. * @param mesh The mesh that this bone is attached to
  13612. * @returns The world direction
  13613. */
  13614. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13615. /**
  13616. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13617. * @param localAxis The local direction that is used to compute the world direction
  13618. * @param mesh The mesh that this bone is attached to
  13619. * @param result The vector3 that the world direction will be copied to
  13620. */
  13621. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13622. /**
  13623. * Get the euler rotation of the bone in local or world space
  13624. * @param space The space that the rotation should be in
  13625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13626. * @returns The euler rotation
  13627. */
  13628. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13629. /**
  13630. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13631. * @param space The space that the rotation should be in
  13632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13633. * @param result The vector3 that the rotation should be copied to
  13634. */
  13635. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13636. /**
  13637. * Get the quaternion rotation of the bone in either local or world space
  13638. * @param space The space that the rotation should be in
  13639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13640. * @returns The quaternion rotation
  13641. */
  13642. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13643. /**
  13644. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13645. * @param space The space that the rotation should be in
  13646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13647. * @param result The quaternion that the rotation should be copied to
  13648. */
  13649. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13650. /**
  13651. * Get the rotation matrix of the bone in local or world space
  13652. * @param space The space that the rotation should be in
  13653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13654. * @returns The rotation matrix
  13655. */
  13656. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13657. /**
  13658. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13659. * @param space The space that the rotation should be in
  13660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13661. * @param result The quaternion that the rotation should be copied to
  13662. */
  13663. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13664. /**
  13665. * Get the world position of a point that is in the local space of the bone
  13666. * @param position The local position
  13667. * @param mesh The mesh that this bone is attached to
  13668. * @returns The world position
  13669. */
  13670. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13671. /**
  13672. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13673. * @param position The local position
  13674. * @param mesh The mesh that this bone is attached to
  13675. * @param result The vector3 that the world position should be copied to
  13676. */
  13677. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13678. /**
  13679. * Get the local position of a point that is in world space
  13680. * @param position The world position
  13681. * @param mesh The mesh that this bone is attached to
  13682. * @returns The local position
  13683. */
  13684. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13685. /**
  13686. * Get the local position of a point that is in world space and copy it to the result param
  13687. * @param position The world position
  13688. * @param mesh The mesh that this bone is attached to
  13689. * @param result The vector3 that the local position should be copied to
  13690. */
  13691. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13692. }
  13693. }
  13694. declare module BABYLON {
  13695. /**
  13696. * 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.
  13697. * @see https://doc.babylonjs.com/how_to/transformnode
  13698. */
  13699. export class TransformNode extends Node {
  13700. /**
  13701. * Object will not rotate to face the camera
  13702. */
  13703. static BILLBOARDMODE_NONE: number;
  13704. /**
  13705. * Object will rotate to face the camera but only on the x axis
  13706. */
  13707. static BILLBOARDMODE_X: number;
  13708. /**
  13709. * Object will rotate to face the camera but only on the y axis
  13710. */
  13711. static BILLBOARDMODE_Y: number;
  13712. /**
  13713. * Object will rotate to face the camera but only on the z axis
  13714. */
  13715. static BILLBOARDMODE_Z: number;
  13716. /**
  13717. * Object will rotate to face the camera
  13718. */
  13719. static BILLBOARDMODE_ALL: number;
  13720. /**
  13721. * Object will rotate to face the camera's position instead of orientation
  13722. */
  13723. static BILLBOARDMODE_USE_POSITION: number;
  13724. private _forward;
  13725. private _forwardInverted;
  13726. private _up;
  13727. private _right;
  13728. private _rightInverted;
  13729. private _position;
  13730. private _rotation;
  13731. private _rotationQuaternion;
  13732. protected _scaling: Vector3;
  13733. protected _isDirty: boolean;
  13734. private _transformToBoneReferal;
  13735. private _isAbsoluteSynced;
  13736. private _billboardMode;
  13737. /**
  13738. * Gets or sets the billboard mode. Default is 0.
  13739. *
  13740. * | Value | Type | Description |
  13741. * | --- | --- | --- |
  13742. * | 0 | BILLBOARDMODE_NONE | |
  13743. * | 1 | BILLBOARDMODE_X | |
  13744. * | 2 | BILLBOARDMODE_Y | |
  13745. * | 4 | BILLBOARDMODE_Z | |
  13746. * | 7 | BILLBOARDMODE_ALL | |
  13747. *
  13748. */
  13749. billboardMode: number;
  13750. private _preserveParentRotationForBillboard;
  13751. /**
  13752. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13753. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13754. */
  13755. preserveParentRotationForBillboard: boolean;
  13756. /**
  13757. * 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
  13758. */
  13759. scalingDeterminant: number;
  13760. private _infiniteDistance;
  13761. /**
  13762. * Gets or sets the distance of the object to max, often used by skybox
  13763. */
  13764. infiniteDistance: boolean;
  13765. /**
  13766. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13767. * By default the system will update normals to compensate
  13768. */
  13769. ignoreNonUniformScaling: boolean;
  13770. /**
  13771. * 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
  13772. */
  13773. reIntegrateRotationIntoRotationQuaternion: boolean;
  13774. /** @hidden */
  13775. _poseMatrix: Nullable<Matrix>;
  13776. /** @hidden */
  13777. _localMatrix: Matrix;
  13778. private _usePivotMatrix;
  13779. private _absolutePosition;
  13780. private _absoluteScaling;
  13781. private _absoluteRotationQuaternion;
  13782. private _pivotMatrix;
  13783. private _pivotMatrixInverse;
  13784. protected _postMultiplyPivotMatrix: boolean;
  13785. protected _isWorldMatrixFrozen: boolean;
  13786. /** @hidden */
  13787. _indexInSceneTransformNodesArray: number;
  13788. /**
  13789. * An event triggered after the world matrix is updated
  13790. */
  13791. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13792. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13793. /**
  13794. * Gets a string identifying the name of the class
  13795. * @returns "TransformNode" string
  13796. */
  13797. getClassName(): string;
  13798. /**
  13799. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13800. */
  13801. position: Vector3;
  13802. /**
  13803. * 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)).
  13804. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13805. */
  13806. rotation: Vector3;
  13807. /**
  13808. * 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)).
  13809. */
  13810. scaling: Vector3;
  13811. /**
  13812. * 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).
  13813. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13814. */
  13815. rotationQuaternion: Nullable<Quaternion>;
  13816. /**
  13817. * The forward direction of that transform in world space.
  13818. */
  13819. readonly forward: Vector3;
  13820. /**
  13821. * The up direction of that transform in world space.
  13822. */
  13823. readonly up: Vector3;
  13824. /**
  13825. * The right direction of that transform in world space.
  13826. */
  13827. readonly right: Vector3;
  13828. /**
  13829. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13830. * @param matrix the matrix to copy the pose from
  13831. * @returns this TransformNode.
  13832. */
  13833. updatePoseMatrix(matrix: Matrix): TransformNode;
  13834. /**
  13835. * Returns the mesh Pose matrix.
  13836. * @returns the pose matrix
  13837. */
  13838. getPoseMatrix(): Matrix;
  13839. /** @hidden */
  13840. _isSynchronized(): boolean;
  13841. /** @hidden */
  13842. _initCache(): void;
  13843. /**
  13844. * Flag the transform node as dirty (Forcing it to update everything)
  13845. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13846. * @returns this transform node
  13847. */
  13848. markAsDirty(property: string): TransformNode;
  13849. /**
  13850. * Returns the current mesh absolute position.
  13851. * Returns a Vector3.
  13852. */
  13853. readonly absolutePosition: Vector3;
  13854. /**
  13855. * Returns the current mesh absolute scaling.
  13856. * Returns a Vector3.
  13857. */
  13858. readonly absoluteScaling: Vector3;
  13859. /**
  13860. * Returns the current mesh absolute rotation.
  13861. * Returns a Quaternion.
  13862. */
  13863. readonly absoluteRotationQuaternion: Quaternion;
  13864. /**
  13865. * Sets a new matrix to apply before all other transformation
  13866. * @param matrix defines the transform matrix
  13867. * @returns the current TransformNode
  13868. */
  13869. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13870. /**
  13871. * Sets a new pivot matrix to the current node
  13872. * @param matrix defines the new pivot matrix to use
  13873. * @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
  13874. * @returns the current TransformNode
  13875. */
  13876. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13877. /**
  13878. * Returns the mesh pivot matrix.
  13879. * Default : Identity.
  13880. * @returns the matrix
  13881. */
  13882. getPivotMatrix(): Matrix;
  13883. /**
  13884. * Instantiate (when possible) or clone that node with its hierarchy
  13885. * @param newParent defines the new parent to use for the instance (or clone)
  13886. * @returns an instance (or a clone) of the current node with its hiearchy
  13887. */
  13888. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13889. /**
  13890. * Prevents the World matrix to be computed any longer
  13891. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13892. * @returns the TransformNode.
  13893. */
  13894. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13895. /**
  13896. * Allows back the World matrix computation.
  13897. * @returns the TransformNode.
  13898. */
  13899. unfreezeWorldMatrix(): this;
  13900. /**
  13901. * True if the World matrix has been frozen.
  13902. */
  13903. readonly isWorldMatrixFrozen: boolean;
  13904. /**
  13905. * Retuns the mesh absolute position in the World.
  13906. * @returns a Vector3.
  13907. */
  13908. getAbsolutePosition(): Vector3;
  13909. /**
  13910. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13911. * @param absolutePosition the absolute position to set
  13912. * @returns the TransformNode.
  13913. */
  13914. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13915. /**
  13916. * Sets the mesh position in its local space.
  13917. * @param vector3 the position to set in localspace
  13918. * @returns the TransformNode.
  13919. */
  13920. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13921. /**
  13922. * Returns the mesh position in the local space from the current World matrix values.
  13923. * @returns a new Vector3.
  13924. */
  13925. getPositionExpressedInLocalSpace(): Vector3;
  13926. /**
  13927. * Translates the mesh along the passed Vector3 in its local space.
  13928. * @param vector3 the distance to translate in localspace
  13929. * @returns the TransformNode.
  13930. */
  13931. locallyTranslate(vector3: Vector3): TransformNode;
  13932. private static _lookAtVectorCache;
  13933. /**
  13934. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13935. * @param targetPoint the position (must be in same space as current mesh) to look at
  13936. * @param yawCor optional yaw (y-axis) correction in radians
  13937. * @param pitchCor optional pitch (x-axis) correction in radians
  13938. * @param rollCor optional roll (z-axis) correction in radians
  13939. * @param space the choosen space of the target
  13940. * @returns the TransformNode.
  13941. */
  13942. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13943. /**
  13944. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13945. * This Vector3 is expressed in the World space.
  13946. * @param localAxis axis to rotate
  13947. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13948. */
  13949. getDirection(localAxis: Vector3): Vector3;
  13950. /**
  13951. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13952. * localAxis is expressed in the mesh local space.
  13953. * result is computed in the Wordl space from the mesh World matrix.
  13954. * @param localAxis axis to rotate
  13955. * @param result the resulting transformnode
  13956. * @returns this TransformNode.
  13957. */
  13958. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13959. /**
  13960. * Sets this transform node rotation to the given local axis.
  13961. * @param localAxis the axis in local space
  13962. * @param yawCor optional yaw (y-axis) correction in radians
  13963. * @param pitchCor optional pitch (x-axis) correction in radians
  13964. * @param rollCor optional roll (z-axis) correction in radians
  13965. * @returns this TransformNode
  13966. */
  13967. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13968. /**
  13969. * Sets a new pivot point to the current node
  13970. * @param point defines the new pivot point to use
  13971. * @param space defines if the point is in world or local space (local by default)
  13972. * @returns the current TransformNode
  13973. */
  13974. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13975. /**
  13976. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13977. * @returns the pivot point
  13978. */
  13979. getPivotPoint(): Vector3;
  13980. /**
  13981. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13982. * @param result the vector3 to store the result
  13983. * @returns this TransformNode.
  13984. */
  13985. getPivotPointToRef(result: Vector3): TransformNode;
  13986. /**
  13987. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13988. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13989. */
  13990. getAbsolutePivotPoint(): Vector3;
  13991. /**
  13992. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13993. * @param result vector3 to store the result
  13994. * @returns this TransformNode.
  13995. */
  13996. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13997. /**
  13998. * Defines the passed node as the parent of the current node.
  13999. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14000. * @see https://doc.babylonjs.com/how_to/parenting
  14001. * @param node the node ot set as the parent
  14002. * @returns this TransformNode.
  14003. */
  14004. setParent(node: Nullable<Node>): TransformNode;
  14005. private _nonUniformScaling;
  14006. /**
  14007. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14008. */
  14009. readonly nonUniformScaling: boolean;
  14010. /** @hidden */
  14011. _updateNonUniformScalingState(value: boolean): boolean;
  14012. /**
  14013. * Attach the current TransformNode to another TransformNode associated with a bone
  14014. * @param bone Bone affecting the TransformNode
  14015. * @param affectedTransformNode TransformNode associated with the bone
  14016. * @returns this object
  14017. */
  14018. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14019. /**
  14020. * Detach the transform node if its associated with a bone
  14021. * @returns this object
  14022. */
  14023. detachFromBone(): TransformNode;
  14024. private static _rotationAxisCache;
  14025. /**
  14026. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14027. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14028. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14029. * The passed axis is also normalized.
  14030. * @param axis the axis to rotate around
  14031. * @param amount the amount to rotate in radians
  14032. * @param space Space to rotate in (Default: local)
  14033. * @returns the TransformNode.
  14034. */
  14035. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14036. /**
  14037. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14038. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14039. * The passed axis is also normalized. .
  14040. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14041. * @param point the point to rotate around
  14042. * @param axis the axis to rotate around
  14043. * @param amount the amount to rotate in radians
  14044. * @returns the TransformNode
  14045. */
  14046. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14047. /**
  14048. * Translates the mesh along the axis vector for the passed distance in the given space.
  14049. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14050. * @param axis the axis to translate in
  14051. * @param distance the distance to translate
  14052. * @param space Space to rotate in (Default: local)
  14053. * @returns the TransformNode.
  14054. */
  14055. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14056. /**
  14057. * Adds a rotation step to the mesh current rotation.
  14058. * x, y, z are Euler angles expressed in radians.
  14059. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14060. * This means this rotation is made in the mesh local space only.
  14061. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14062. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14063. * ```javascript
  14064. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14065. * ```
  14066. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14067. * 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.
  14068. * @param x Rotation to add
  14069. * @param y Rotation to add
  14070. * @param z Rotation to add
  14071. * @returns the TransformNode.
  14072. */
  14073. addRotation(x: number, y: number, z: number): TransformNode;
  14074. /**
  14075. * @hidden
  14076. */
  14077. protected _getEffectiveParent(): Nullable<Node>;
  14078. /**
  14079. * Computes the world matrix of the node
  14080. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14081. * @returns the world matrix
  14082. */
  14083. computeWorldMatrix(force?: boolean): Matrix;
  14084. protected _afterComputeWorldMatrix(): void;
  14085. /**
  14086. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14087. * @param func callback function to add
  14088. *
  14089. * @returns the TransformNode.
  14090. */
  14091. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14092. /**
  14093. * Removes a registered callback function.
  14094. * @param func callback function to remove
  14095. * @returns the TransformNode.
  14096. */
  14097. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14098. /**
  14099. * Gets the position of the current mesh in camera space
  14100. * @param camera defines the camera to use
  14101. * @returns a position
  14102. */
  14103. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14104. /**
  14105. * Returns the distance from the mesh to the active camera
  14106. * @param camera defines the camera to use
  14107. * @returns the distance
  14108. */
  14109. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14110. /**
  14111. * Clone the current transform node
  14112. * @param name Name of the new clone
  14113. * @param newParent New parent for the clone
  14114. * @param doNotCloneChildren Do not clone children hierarchy
  14115. * @returns the new transform node
  14116. */
  14117. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14118. /**
  14119. * Serializes the objects information.
  14120. * @param currentSerializationObject defines the object to serialize in
  14121. * @returns the serialized object
  14122. */
  14123. serialize(currentSerializationObject?: any): any;
  14124. /**
  14125. * Returns a new TransformNode object parsed from the source provided.
  14126. * @param parsedTransformNode is the source.
  14127. * @param scene the scne the object belongs to
  14128. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14129. * @returns a new TransformNode object parsed from the source provided.
  14130. */
  14131. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14132. /**
  14133. * Get all child-transformNodes of this node
  14134. * @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
  14135. * @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
  14136. * @returns an array of TransformNode
  14137. */
  14138. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14139. /**
  14140. * Releases resources associated with this transform node.
  14141. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14142. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14143. */
  14144. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14145. /**
  14146. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14147. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14148. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14149. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14150. * @returns the current mesh
  14151. */
  14152. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14153. private _syncAbsoluteScalingAndRotation;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /**
  14158. * Defines the types of pose enabled controllers that are supported
  14159. */
  14160. export enum PoseEnabledControllerType {
  14161. /**
  14162. * HTC Vive
  14163. */
  14164. VIVE = 0,
  14165. /**
  14166. * Oculus Rift
  14167. */
  14168. OCULUS = 1,
  14169. /**
  14170. * Windows mixed reality
  14171. */
  14172. WINDOWS = 2,
  14173. /**
  14174. * Samsung gear VR
  14175. */
  14176. GEAR_VR = 3,
  14177. /**
  14178. * Google Daydream
  14179. */
  14180. DAYDREAM = 4,
  14181. /**
  14182. * Generic
  14183. */
  14184. GENERIC = 5
  14185. }
  14186. /**
  14187. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14188. */
  14189. export interface MutableGamepadButton {
  14190. /**
  14191. * Value of the button/trigger
  14192. */
  14193. value: number;
  14194. /**
  14195. * If the button/trigger is currently touched
  14196. */
  14197. touched: boolean;
  14198. /**
  14199. * If the button/trigger is currently pressed
  14200. */
  14201. pressed: boolean;
  14202. }
  14203. /**
  14204. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14205. * @hidden
  14206. */
  14207. export interface ExtendedGamepadButton extends GamepadButton {
  14208. /**
  14209. * If the button/trigger is currently pressed
  14210. */
  14211. readonly pressed: boolean;
  14212. /**
  14213. * If the button/trigger is currently touched
  14214. */
  14215. readonly touched: boolean;
  14216. /**
  14217. * Value of the button/trigger
  14218. */
  14219. readonly value: number;
  14220. }
  14221. /** @hidden */
  14222. export interface _GamePadFactory {
  14223. /**
  14224. * Returns wether or not the current gamepad can be created for this type of controller.
  14225. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14226. * @returns true if it can be created, otherwise false
  14227. */
  14228. canCreate(gamepadInfo: any): boolean;
  14229. /**
  14230. * Creates a new instance of the Gamepad.
  14231. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14232. * @returns the new gamepad instance
  14233. */
  14234. create(gamepadInfo: any): Gamepad;
  14235. }
  14236. /**
  14237. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14238. */
  14239. export class PoseEnabledControllerHelper {
  14240. /** @hidden */
  14241. static _ControllerFactories: _GamePadFactory[];
  14242. /** @hidden */
  14243. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14244. /**
  14245. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14246. * @param vrGamepad the gamepad to initialized
  14247. * @returns a vr controller of the type the gamepad identified as
  14248. */
  14249. static InitiateController(vrGamepad: any): Gamepad;
  14250. }
  14251. /**
  14252. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14253. */
  14254. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14255. /**
  14256. * If the controller is used in a webXR session
  14257. */
  14258. isXR: boolean;
  14259. private _deviceRoomPosition;
  14260. private _deviceRoomRotationQuaternion;
  14261. /**
  14262. * The device position in babylon space
  14263. */
  14264. devicePosition: Vector3;
  14265. /**
  14266. * The device rotation in babylon space
  14267. */
  14268. deviceRotationQuaternion: Quaternion;
  14269. /**
  14270. * The scale factor of the device in babylon space
  14271. */
  14272. deviceScaleFactor: number;
  14273. /**
  14274. * (Likely devicePosition should be used instead) The device position in its room space
  14275. */
  14276. position: Vector3;
  14277. /**
  14278. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14279. */
  14280. rotationQuaternion: Quaternion;
  14281. /**
  14282. * The type of controller (Eg. Windows mixed reality)
  14283. */
  14284. controllerType: PoseEnabledControllerType;
  14285. protected _calculatedPosition: Vector3;
  14286. private _calculatedRotation;
  14287. /**
  14288. * The raw pose from the device
  14289. */
  14290. rawPose: DevicePose;
  14291. private _trackPosition;
  14292. private _maxRotationDistFromHeadset;
  14293. private _draggedRoomRotation;
  14294. /**
  14295. * @hidden
  14296. */
  14297. _disableTrackPosition(fixedPosition: Vector3): void;
  14298. /**
  14299. * Internal, the mesh attached to the controller
  14300. * @hidden
  14301. */
  14302. _mesh: Nullable<AbstractMesh>;
  14303. private _poseControlledCamera;
  14304. private _leftHandSystemQuaternion;
  14305. /**
  14306. * Internal, matrix used to convert room space to babylon space
  14307. * @hidden
  14308. */
  14309. _deviceToWorld: Matrix;
  14310. /**
  14311. * Node to be used when casting a ray from the controller
  14312. * @hidden
  14313. */
  14314. _pointingPoseNode: Nullable<TransformNode>;
  14315. /**
  14316. * Name of the child mesh that can be used to cast a ray from the controller
  14317. */
  14318. static readonly POINTING_POSE: string;
  14319. /**
  14320. * Creates a new PoseEnabledController from a gamepad
  14321. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14322. */
  14323. constructor(browserGamepad: any);
  14324. private _workingMatrix;
  14325. /**
  14326. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14327. */
  14328. update(): void;
  14329. /**
  14330. * Updates only the pose device and mesh without doing any button event checking
  14331. */
  14332. protected _updatePoseAndMesh(): void;
  14333. /**
  14334. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14335. * @param poseData raw pose fromthe device
  14336. */
  14337. updateFromDevice(poseData: DevicePose): void;
  14338. /**
  14339. * @hidden
  14340. */
  14341. _meshAttachedObservable: Observable<AbstractMesh>;
  14342. /**
  14343. * Attaches a mesh to the controller
  14344. * @param mesh the mesh to be attached
  14345. */
  14346. attachToMesh(mesh: AbstractMesh): void;
  14347. /**
  14348. * Attaches the controllers mesh to a camera
  14349. * @param camera the camera the mesh should be attached to
  14350. */
  14351. attachToPoseControlledCamera(camera: TargetCamera): void;
  14352. /**
  14353. * Disposes of the controller
  14354. */
  14355. dispose(): void;
  14356. /**
  14357. * The mesh that is attached to the controller
  14358. */
  14359. readonly mesh: Nullable<AbstractMesh>;
  14360. /**
  14361. * Gets the ray of the controller in the direction the controller is pointing
  14362. * @param length the length the resulting ray should be
  14363. * @returns a ray in the direction the controller is pointing
  14364. */
  14365. getForwardRay(length?: number): Ray;
  14366. }
  14367. }
  14368. declare module BABYLON {
  14369. /**
  14370. * Defines the WebVRController object that represents controllers tracked in 3D space
  14371. */
  14372. export abstract class WebVRController extends PoseEnabledController {
  14373. /**
  14374. * Internal, the default controller model for the controller
  14375. */
  14376. protected _defaultModel: AbstractMesh;
  14377. /**
  14378. * Fired when the trigger state has changed
  14379. */
  14380. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14381. /**
  14382. * Fired when the main button state has changed
  14383. */
  14384. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14385. /**
  14386. * Fired when the secondary button state has changed
  14387. */
  14388. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14389. /**
  14390. * Fired when the pad state has changed
  14391. */
  14392. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14393. /**
  14394. * Fired when controllers stick values have changed
  14395. */
  14396. onPadValuesChangedObservable: Observable<StickValues>;
  14397. /**
  14398. * Array of button availible on the controller
  14399. */
  14400. protected _buttons: Array<MutableGamepadButton>;
  14401. private _onButtonStateChange;
  14402. /**
  14403. * Fired when a controller button's state has changed
  14404. * @param callback the callback containing the button that was modified
  14405. */
  14406. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14407. /**
  14408. * X and Y axis corresponding to the controllers joystick
  14409. */
  14410. pad: StickValues;
  14411. /**
  14412. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14413. */
  14414. hand: string;
  14415. /**
  14416. * The default controller model for the controller
  14417. */
  14418. readonly defaultModel: AbstractMesh;
  14419. /**
  14420. * Creates a new WebVRController from a gamepad
  14421. * @param vrGamepad the gamepad that the WebVRController should be created from
  14422. */
  14423. constructor(vrGamepad: any);
  14424. /**
  14425. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14426. */
  14427. update(): void;
  14428. /**
  14429. * Function to be called when a button is modified
  14430. */
  14431. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14432. /**
  14433. * Loads a mesh and attaches it to the controller
  14434. * @param scene the scene the mesh should be added to
  14435. * @param meshLoaded callback for when the mesh has been loaded
  14436. */
  14437. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14438. private _setButtonValue;
  14439. private _changes;
  14440. private _checkChanges;
  14441. /**
  14442. * Disposes of th webVRCOntroller
  14443. */
  14444. dispose(): void;
  14445. }
  14446. }
  14447. declare module BABYLON {
  14448. /**
  14449. * The HemisphericLight simulates the ambient environment light,
  14450. * so the passed direction is the light reflection direction, not the incoming direction.
  14451. */
  14452. export class HemisphericLight extends Light {
  14453. /**
  14454. * The groundColor is the light in the opposite direction to the one specified during creation.
  14455. * 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.
  14456. */
  14457. groundColor: Color3;
  14458. /**
  14459. * The light reflection direction, not the incoming direction.
  14460. */
  14461. direction: Vector3;
  14462. /**
  14463. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14464. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14465. * The HemisphericLight can't cast shadows.
  14466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14467. * @param name The friendly name of the light
  14468. * @param direction The direction of the light reflection
  14469. * @param scene The scene the light belongs to
  14470. */
  14471. constructor(name: string, direction: Vector3, scene: Scene);
  14472. protected _buildUniformLayout(): void;
  14473. /**
  14474. * Returns the string "HemisphericLight".
  14475. * @return The class name
  14476. */
  14477. getClassName(): string;
  14478. /**
  14479. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14480. * Returns the updated direction.
  14481. * @param target The target the direction should point to
  14482. * @return The computed direction
  14483. */
  14484. setDirectionToTarget(target: Vector3): Vector3;
  14485. /**
  14486. * Returns the shadow generator associated to the light.
  14487. * @returns Always null for hemispheric lights because it does not support shadows.
  14488. */
  14489. getShadowGenerator(): Nullable<IShadowGenerator>;
  14490. /**
  14491. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14492. * @param effect The effect to update
  14493. * @param lightIndex The index of the light in the effect to update
  14494. * @returns The hemispheric light
  14495. */
  14496. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14497. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14498. /**
  14499. * Computes the world matrix of the node
  14500. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14501. * @param useWasUpdatedFlag defines a reserved property
  14502. * @returns the world matrix
  14503. */
  14504. computeWorldMatrix(): Matrix;
  14505. /**
  14506. * Returns the integer 3.
  14507. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14508. */
  14509. getTypeID(): number;
  14510. /**
  14511. * Prepares the list of defines specific to the light type.
  14512. * @param defines the list of defines
  14513. * @param lightIndex defines the index of the light for the effect
  14514. */
  14515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14516. }
  14517. }
  14518. declare module BABYLON {
  14519. /** @hidden */
  14520. export var vrMultiviewToSingleviewPixelShader: {
  14521. name: string;
  14522. shader: string;
  14523. };
  14524. }
  14525. declare module BABYLON {
  14526. /**
  14527. * Renders to multiple views with a single draw call
  14528. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14529. */
  14530. export class MultiviewRenderTarget extends RenderTargetTexture {
  14531. /**
  14532. * Creates a multiview render target
  14533. * @param scene scene used with the render target
  14534. * @param size the size of the render target (used for each view)
  14535. */
  14536. constructor(scene: Scene, size?: number | {
  14537. width: number;
  14538. height: number;
  14539. } | {
  14540. ratio: number;
  14541. });
  14542. /**
  14543. * @hidden
  14544. * @param faceIndex the face index, if its a cube texture
  14545. */
  14546. _bindFrameBuffer(faceIndex?: number): void;
  14547. /**
  14548. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14549. * @returns the view count
  14550. */
  14551. getViewCount(): number;
  14552. }
  14553. }
  14554. declare module BABYLON {
  14555. /**
  14556. * Represents a camera frustum
  14557. */
  14558. export class Frustum {
  14559. /**
  14560. * Gets the planes representing the frustum
  14561. * @param transform matrix to be applied to the returned planes
  14562. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14563. */
  14564. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14565. /**
  14566. * Gets the near frustum plane transformed by the transform matrix
  14567. * @param transform transformation matrix to be applied to the resulting frustum plane
  14568. * @param frustumPlane the resuling frustum plane
  14569. */
  14570. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14571. /**
  14572. * Gets the far frustum plane transformed by the transform matrix
  14573. * @param transform transformation matrix to be applied to the resulting frustum plane
  14574. * @param frustumPlane the resuling frustum plane
  14575. */
  14576. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14577. /**
  14578. * Gets the left frustum plane transformed by the transform matrix
  14579. * @param transform transformation matrix to be applied to the resulting frustum plane
  14580. * @param frustumPlane the resuling frustum plane
  14581. */
  14582. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14583. /**
  14584. * Gets the right frustum plane transformed by the transform matrix
  14585. * @param transform transformation matrix to be applied to the resulting frustum plane
  14586. * @param frustumPlane the resuling frustum plane
  14587. */
  14588. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14589. /**
  14590. * Gets the top frustum plane transformed by the transform matrix
  14591. * @param transform transformation matrix to be applied to the resulting frustum plane
  14592. * @param frustumPlane the resuling frustum plane
  14593. */
  14594. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14595. /**
  14596. * Gets the bottom frustum plane transformed by the transform matrix
  14597. * @param transform transformation matrix to be applied to the resulting frustum plane
  14598. * @param frustumPlane the resuling frustum plane
  14599. */
  14600. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14601. /**
  14602. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14603. * @param transform transformation matrix to be applied to the resulting frustum planes
  14604. * @param frustumPlanes the resuling frustum planes
  14605. */
  14606. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14607. }
  14608. }
  14609. declare module BABYLON {
  14610. interface Engine {
  14611. /**
  14612. * Creates a new multiview render target
  14613. * @param width defines the width of the texture
  14614. * @param height defines the height of the texture
  14615. * @returns the created multiview texture
  14616. */
  14617. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14618. /**
  14619. * Binds a multiview framebuffer to be drawn to
  14620. * @param multiviewTexture texture to bind
  14621. */
  14622. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14623. }
  14624. interface Camera {
  14625. /**
  14626. * @hidden
  14627. * 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)
  14628. */
  14629. _useMultiviewToSingleView: boolean;
  14630. /**
  14631. * @hidden
  14632. * 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)
  14633. */
  14634. _multiviewTexture: Nullable<RenderTargetTexture>;
  14635. /**
  14636. * @hidden
  14637. * ensures the multiview texture of the camera exists and has the specified width/height
  14638. * @param width height to set on the multiview texture
  14639. * @param height width to set on the multiview texture
  14640. */
  14641. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14642. }
  14643. interface Scene {
  14644. /** @hidden */
  14645. _transformMatrixR: Matrix;
  14646. /** @hidden */
  14647. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14648. /** @hidden */
  14649. _createMultiviewUbo(): void;
  14650. /** @hidden */
  14651. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14652. /** @hidden */
  14653. _renderMultiviewToSingleView(camera: Camera): void;
  14654. }
  14655. }
  14656. declare module BABYLON {
  14657. /**
  14658. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14659. * This will not be used for webXR as it supports displaying texture arrays directly
  14660. */
  14661. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14662. /**
  14663. * Initializes a VRMultiviewToSingleview
  14664. * @param name name of the post process
  14665. * @param camera camera to be applied to
  14666. * @param scaleFactor scaling factor to the size of the output texture
  14667. */
  14668. constructor(name: string, camera: Camera, scaleFactor: number);
  14669. }
  14670. }
  14671. declare module BABYLON {
  14672. interface Engine {
  14673. /** @hidden */
  14674. _vrDisplay: any;
  14675. /** @hidden */
  14676. _vrSupported: boolean;
  14677. /** @hidden */
  14678. _oldSize: Size;
  14679. /** @hidden */
  14680. _oldHardwareScaleFactor: number;
  14681. /** @hidden */
  14682. _vrExclusivePointerMode: boolean;
  14683. /** @hidden */
  14684. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14685. /** @hidden */
  14686. _onVRDisplayPointerRestricted: () => void;
  14687. /** @hidden */
  14688. _onVRDisplayPointerUnrestricted: () => void;
  14689. /** @hidden */
  14690. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14691. /** @hidden */
  14692. _onVrDisplayDisconnect: Nullable<() => void>;
  14693. /** @hidden */
  14694. _onVrDisplayPresentChange: Nullable<() => void>;
  14695. /**
  14696. * Observable signaled when VR display mode changes
  14697. */
  14698. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14699. /**
  14700. * Observable signaled when VR request present is complete
  14701. */
  14702. onVRRequestPresentComplete: Observable<boolean>;
  14703. /**
  14704. * Observable signaled when VR request present starts
  14705. */
  14706. onVRRequestPresentStart: Observable<Engine>;
  14707. /**
  14708. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14709. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14710. */
  14711. isInVRExclusivePointerMode: boolean;
  14712. /**
  14713. * Gets a boolean indicating if a webVR device was detected
  14714. * @returns true if a webVR device was detected
  14715. */
  14716. isVRDevicePresent(): boolean;
  14717. /**
  14718. * Gets the current webVR device
  14719. * @returns the current webVR device (or null)
  14720. */
  14721. getVRDevice(): any;
  14722. /**
  14723. * Initializes a webVR display and starts listening to display change events
  14724. * The onVRDisplayChangedObservable will be notified upon these changes
  14725. * @returns A promise containing a VRDisplay and if vr is supported
  14726. */
  14727. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14728. /** @hidden */
  14729. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14730. /**
  14731. * Call this function to switch to webVR mode
  14732. * Will do nothing if webVR is not supported or if there is no webVR device
  14733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14734. */
  14735. enableVR(): void;
  14736. /** @hidden */
  14737. _onVRFullScreenTriggered(): void;
  14738. }
  14739. }
  14740. declare module BABYLON {
  14741. /**
  14742. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14743. * IMPORTANT!! The data is right-hand data.
  14744. * @export
  14745. * @interface DevicePose
  14746. */
  14747. export interface DevicePose {
  14748. /**
  14749. * The position of the device, values in array are [x,y,z].
  14750. */
  14751. readonly position: Nullable<Float32Array>;
  14752. /**
  14753. * The linearVelocity of the device, values in array are [x,y,z].
  14754. */
  14755. readonly linearVelocity: Nullable<Float32Array>;
  14756. /**
  14757. * The linearAcceleration of the device, values in array are [x,y,z].
  14758. */
  14759. readonly linearAcceleration: Nullable<Float32Array>;
  14760. /**
  14761. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14762. */
  14763. readonly orientation: Nullable<Float32Array>;
  14764. /**
  14765. * The angularVelocity of the device, values in array are [x,y,z].
  14766. */
  14767. readonly angularVelocity: Nullable<Float32Array>;
  14768. /**
  14769. * The angularAcceleration of the device, values in array are [x,y,z].
  14770. */
  14771. readonly angularAcceleration: Nullable<Float32Array>;
  14772. }
  14773. /**
  14774. * Interface representing a pose controlled object in Babylon.
  14775. * A pose controlled object has both regular pose values as well as pose values
  14776. * from an external device such as a VR head mounted display
  14777. */
  14778. export interface PoseControlled {
  14779. /**
  14780. * The position of the object in babylon space.
  14781. */
  14782. position: Vector3;
  14783. /**
  14784. * The rotation quaternion of the object in babylon space.
  14785. */
  14786. rotationQuaternion: Quaternion;
  14787. /**
  14788. * The position of the device in babylon space.
  14789. */
  14790. devicePosition?: Vector3;
  14791. /**
  14792. * The rotation quaternion of the device in babylon space.
  14793. */
  14794. deviceRotationQuaternion: Quaternion;
  14795. /**
  14796. * The raw pose coming from the device.
  14797. */
  14798. rawPose: Nullable<DevicePose>;
  14799. /**
  14800. * The scale of the device to be used when translating from device space to babylon space.
  14801. */
  14802. deviceScaleFactor: number;
  14803. /**
  14804. * Updates the poseControlled values based on the input device pose.
  14805. * @param poseData the pose data to update the object with
  14806. */
  14807. updateFromDevice(poseData: DevicePose): void;
  14808. }
  14809. /**
  14810. * Set of options to customize the webVRCamera
  14811. */
  14812. export interface WebVROptions {
  14813. /**
  14814. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14815. */
  14816. trackPosition?: boolean;
  14817. /**
  14818. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14819. */
  14820. positionScale?: number;
  14821. /**
  14822. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14823. */
  14824. displayName?: string;
  14825. /**
  14826. * Should the native controller meshes be initialized. (default: true)
  14827. */
  14828. controllerMeshes?: boolean;
  14829. /**
  14830. * Creating a default HemiLight only on controllers. (default: true)
  14831. */
  14832. defaultLightingOnControllers?: boolean;
  14833. /**
  14834. * If you don't want to use the default VR button of the helper. (default: false)
  14835. */
  14836. useCustomVRButton?: boolean;
  14837. /**
  14838. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14839. */
  14840. customVRButton?: HTMLButtonElement;
  14841. /**
  14842. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14843. */
  14844. rayLength?: number;
  14845. /**
  14846. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14847. */
  14848. defaultHeight?: number;
  14849. /**
  14850. * If multiview should be used if availible (default: false)
  14851. */
  14852. useMultiview?: boolean;
  14853. }
  14854. /**
  14855. * This represents a WebVR camera.
  14856. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14857. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14858. */
  14859. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14860. private webVROptions;
  14861. /**
  14862. * @hidden
  14863. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14864. */
  14865. _vrDevice: any;
  14866. /**
  14867. * The rawPose of the vrDevice.
  14868. */
  14869. rawPose: Nullable<DevicePose>;
  14870. private _onVREnabled;
  14871. private _specsVersion;
  14872. private _attached;
  14873. private _frameData;
  14874. protected _descendants: Array<Node>;
  14875. private _deviceRoomPosition;
  14876. /** @hidden */
  14877. _deviceRoomRotationQuaternion: Quaternion;
  14878. private _standingMatrix;
  14879. /**
  14880. * Represents device position in babylon space.
  14881. */
  14882. devicePosition: Vector3;
  14883. /**
  14884. * Represents device rotation in babylon space.
  14885. */
  14886. deviceRotationQuaternion: Quaternion;
  14887. /**
  14888. * The scale of the device to be used when translating from device space to babylon space.
  14889. */
  14890. deviceScaleFactor: number;
  14891. private _deviceToWorld;
  14892. private _worldToDevice;
  14893. /**
  14894. * References to the webVR controllers for the vrDevice.
  14895. */
  14896. controllers: Array<WebVRController>;
  14897. /**
  14898. * Emits an event when a controller is attached.
  14899. */
  14900. onControllersAttachedObservable: Observable<WebVRController[]>;
  14901. /**
  14902. * Emits an event when a controller's mesh has been loaded;
  14903. */
  14904. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14905. /**
  14906. * Emits an event when the HMD's pose has been updated.
  14907. */
  14908. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14909. private _poseSet;
  14910. /**
  14911. * If the rig cameras be used as parent instead of this camera.
  14912. */
  14913. rigParenting: boolean;
  14914. private _lightOnControllers;
  14915. private _defaultHeight?;
  14916. /**
  14917. * Instantiates a WebVRFreeCamera.
  14918. * @param name The name of the WebVRFreeCamera
  14919. * @param position The starting anchor position for the camera
  14920. * @param scene The scene the camera belongs to
  14921. * @param webVROptions a set of customizable options for the webVRCamera
  14922. */
  14923. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14924. /**
  14925. * Gets the device distance from the ground in meters.
  14926. * @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.
  14927. */
  14928. deviceDistanceToRoomGround(): number;
  14929. /**
  14930. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14931. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14932. */
  14933. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14934. /**
  14935. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14936. * @returns A promise with a boolean set to if the standing matrix is supported.
  14937. */
  14938. useStandingMatrixAsync(): Promise<boolean>;
  14939. /**
  14940. * Disposes the camera
  14941. */
  14942. dispose(): void;
  14943. /**
  14944. * Gets a vrController by name.
  14945. * @param name The name of the controller to retreive
  14946. * @returns the controller matching the name specified or null if not found
  14947. */
  14948. getControllerByName(name: string): Nullable<WebVRController>;
  14949. private _leftController;
  14950. /**
  14951. * The controller corresponding to the users left hand.
  14952. */
  14953. readonly leftController: Nullable<WebVRController>;
  14954. private _rightController;
  14955. /**
  14956. * The controller corresponding to the users right hand.
  14957. */
  14958. readonly rightController: Nullable<WebVRController>;
  14959. /**
  14960. * Casts a ray forward from the vrCamera's gaze.
  14961. * @param length Length of the ray (default: 100)
  14962. * @returns the ray corresponding to the gaze
  14963. */
  14964. getForwardRay(length?: number): Ray;
  14965. /**
  14966. * @hidden
  14967. * Updates the camera based on device's frame data
  14968. */
  14969. _checkInputs(): void;
  14970. /**
  14971. * Updates the poseControlled values based on the input device pose.
  14972. * @param poseData Pose coming from the device
  14973. */
  14974. updateFromDevice(poseData: DevicePose): void;
  14975. private _htmlElementAttached;
  14976. private _detachIfAttached;
  14977. /**
  14978. * WebVR's attach control will start broadcasting frames to the device.
  14979. * Note that in certain browsers (chrome for example) this function must be called
  14980. * within a user-interaction callback. Example:
  14981. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14982. *
  14983. * @param element html element to attach the vrDevice to
  14984. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14985. */
  14986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14987. /**
  14988. * Detaches the camera from the html element and disables VR
  14989. *
  14990. * @param element html element to detach from
  14991. */
  14992. detachControl(element: HTMLElement): void;
  14993. /**
  14994. * @returns the name of this class
  14995. */
  14996. getClassName(): string;
  14997. /**
  14998. * Calls resetPose on the vrDisplay
  14999. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15000. */
  15001. resetToCurrentRotation(): void;
  15002. /**
  15003. * @hidden
  15004. * Updates the rig cameras (left and right eye)
  15005. */
  15006. _updateRigCameras(): void;
  15007. private _workingVector;
  15008. private _oneVector;
  15009. private _workingMatrix;
  15010. private updateCacheCalled;
  15011. private _correctPositionIfNotTrackPosition;
  15012. /**
  15013. * @hidden
  15014. * Updates the cached values of the camera
  15015. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15016. */
  15017. _updateCache(ignoreParentClass?: boolean): void;
  15018. /**
  15019. * @hidden
  15020. * Get current device position in babylon world
  15021. */
  15022. _computeDevicePosition(): void;
  15023. /**
  15024. * Updates the current device position and rotation in the babylon world
  15025. */
  15026. update(): void;
  15027. /**
  15028. * @hidden
  15029. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15030. * @returns an identity matrix
  15031. */
  15032. _getViewMatrix(): Matrix;
  15033. private _tmpMatrix;
  15034. /**
  15035. * This function is called by the two RIG cameras.
  15036. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15037. * @hidden
  15038. */
  15039. _getWebVRViewMatrix(): Matrix;
  15040. /** @hidden */
  15041. _getWebVRProjectionMatrix(): Matrix;
  15042. private _onGamepadConnectedObserver;
  15043. private _onGamepadDisconnectedObserver;
  15044. private _updateCacheWhenTrackingDisabledObserver;
  15045. /**
  15046. * Initializes the controllers and their meshes
  15047. */
  15048. initControllers(): void;
  15049. }
  15050. }
  15051. declare module BABYLON {
  15052. /**
  15053. * Size options for a post process
  15054. */
  15055. export type PostProcessOptions = {
  15056. width: number;
  15057. height: number;
  15058. };
  15059. /**
  15060. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15061. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15062. */
  15063. export class PostProcess {
  15064. /** Name of the PostProcess. */
  15065. name: string;
  15066. /**
  15067. * Gets or sets the unique id of the post process
  15068. */
  15069. uniqueId: number;
  15070. /**
  15071. * Width of the texture to apply the post process on
  15072. */
  15073. width: number;
  15074. /**
  15075. * Height of the texture to apply the post process on
  15076. */
  15077. height: number;
  15078. /**
  15079. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15080. * @hidden
  15081. */
  15082. _outputTexture: Nullable<InternalTexture>;
  15083. /**
  15084. * Sampling mode used by the shader
  15085. * See https://doc.babylonjs.com/classes/3.1/texture
  15086. */
  15087. renderTargetSamplingMode: number;
  15088. /**
  15089. * Clear color to use when screen clearing
  15090. */
  15091. clearColor: Color4;
  15092. /**
  15093. * If the buffer needs to be cleared before applying the post process. (default: true)
  15094. * Should be set to false if shader will overwrite all previous pixels.
  15095. */
  15096. autoClear: boolean;
  15097. /**
  15098. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15099. */
  15100. alphaMode: number;
  15101. /**
  15102. * Sets the setAlphaBlendConstants of the babylon engine
  15103. */
  15104. alphaConstants: Color4;
  15105. /**
  15106. * Animations to be used for the post processing
  15107. */
  15108. animations: Animation[];
  15109. /**
  15110. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15111. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15112. */
  15113. enablePixelPerfectMode: boolean;
  15114. /**
  15115. * Force the postprocess to be applied without taking in account viewport
  15116. */
  15117. forceFullscreenViewport: boolean;
  15118. /**
  15119. * List of inspectable custom properties (used by the Inspector)
  15120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15121. */
  15122. inspectableCustomProperties: IInspectable[];
  15123. /**
  15124. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15125. *
  15126. * | Value | Type | Description |
  15127. * | ----- | ----------------------------------- | ----------- |
  15128. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15129. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15130. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15131. *
  15132. */
  15133. scaleMode: number;
  15134. /**
  15135. * Force textures to be a power of two (default: false)
  15136. */
  15137. alwaysForcePOT: boolean;
  15138. private _samples;
  15139. /**
  15140. * Number of sample textures (default: 1)
  15141. */
  15142. samples: number;
  15143. /**
  15144. * Modify the scale of the post process to be the same as the viewport (default: false)
  15145. */
  15146. adaptScaleToCurrentViewport: boolean;
  15147. private _camera;
  15148. private _scene;
  15149. private _engine;
  15150. private _options;
  15151. private _reusable;
  15152. private _textureType;
  15153. /**
  15154. * Smart array of input and output textures for the post process.
  15155. * @hidden
  15156. */
  15157. _textures: SmartArray<InternalTexture>;
  15158. /**
  15159. * The index in _textures that corresponds to the output texture.
  15160. * @hidden
  15161. */
  15162. _currentRenderTextureInd: number;
  15163. private _effect;
  15164. private _samplers;
  15165. private _fragmentUrl;
  15166. private _vertexUrl;
  15167. private _parameters;
  15168. private _scaleRatio;
  15169. protected _indexParameters: any;
  15170. private _shareOutputWithPostProcess;
  15171. private _texelSize;
  15172. private _forcedOutputTexture;
  15173. /**
  15174. * Returns the fragment url or shader name used in the post process.
  15175. * @returns the fragment url or name in the shader store.
  15176. */
  15177. getEffectName(): string;
  15178. /**
  15179. * An event triggered when the postprocess is activated.
  15180. */
  15181. onActivateObservable: Observable<Camera>;
  15182. private _onActivateObserver;
  15183. /**
  15184. * A function that is added to the onActivateObservable
  15185. */
  15186. onActivate: Nullable<(camera: Camera) => void>;
  15187. /**
  15188. * An event triggered when the postprocess changes its size.
  15189. */
  15190. onSizeChangedObservable: Observable<PostProcess>;
  15191. private _onSizeChangedObserver;
  15192. /**
  15193. * A function that is added to the onSizeChangedObservable
  15194. */
  15195. onSizeChanged: (postProcess: PostProcess) => void;
  15196. /**
  15197. * An event triggered when the postprocess applies its effect.
  15198. */
  15199. onApplyObservable: Observable<Effect>;
  15200. private _onApplyObserver;
  15201. /**
  15202. * A function that is added to the onApplyObservable
  15203. */
  15204. onApply: (effect: Effect) => void;
  15205. /**
  15206. * An event triggered before rendering the postprocess
  15207. */
  15208. onBeforeRenderObservable: Observable<Effect>;
  15209. private _onBeforeRenderObserver;
  15210. /**
  15211. * A function that is added to the onBeforeRenderObservable
  15212. */
  15213. onBeforeRender: (effect: Effect) => void;
  15214. /**
  15215. * An event triggered after rendering the postprocess
  15216. */
  15217. onAfterRenderObservable: Observable<Effect>;
  15218. private _onAfterRenderObserver;
  15219. /**
  15220. * A function that is added to the onAfterRenderObservable
  15221. */
  15222. onAfterRender: (efect: Effect) => void;
  15223. /**
  15224. * 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
  15225. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15226. */
  15227. inputTexture: InternalTexture;
  15228. /**
  15229. * Gets the camera which post process is applied to.
  15230. * @returns The camera the post process is applied to.
  15231. */
  15232. getCamera(): Camera;
  15233. /**
  15234. * Gets the texel size of the postprocess.
  15235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15236. */
  15237. readonly texelSize: Vector2;
  15238. /**
  15239. * Creates a new instance PostProcess
  15240. * @param name The name of the PostProcess.
  15241. * @param fragmentUrl The url of the fragment shader to be used.
  15242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15245. * @param camera The camera to apply the render pass to.
  15246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15247. * @param engine The engine which the post process will be applied. (default: current engine)
  15248. * @param reusable If the post process can be reused on the same frame. (default: false)
  15249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15250. * @param textureType Type of textures used when performing the post process. (default: 0)
  15251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15252. * @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
  15253. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15254. */
  15255. constructor(
  15256. /** Name of the PostProcess. */
  15257. 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);
  15258. /**
  15259. * Gets a string idenfifying the name of the class
  15260. * @returns "PostProcess" string
  15261. */
  15262. getClassName(): string;
  15263. /**
  15264. * Gets the engine which this post process belongs to.
  15265. * @returns The engine the post process was enabled with.
  15266. */
  15267. getEngine(): Engine;
  15268. /**
  15269. * The effect that is created when initializing the post process.
  15270. * @returns The created effect corresponding the the postprocess.
  15271. */
  15272. getEffect(): Effect;
  15273. /**
  15274. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15275. * @param postProcess The post process to share the output with.
  15276. * @returns This post process.
  15277. */
  15278. shareOutputWith(postProcess: PostProcess): PostProcess;
  15279. /**
  15280. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15281. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15282. */
  15283. useOwnOutput(): void;
  15284. /**
  15285. * Updates the effect with the current post process compile time values and recompiles the shader.
  15286. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15287. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15288. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15289. * @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
  15290. * @param onCompiled Called when the shader has been compiled.
  15291. * @param onError Called if there is an error when compiling a shader.
  15292. */
  15293. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15294. /**
  15295. * The post process is reusable if it can be used multiple times within one frame.
  15296. * @returns If the post process is reusable
  15297. */
  15298. isReusable(): boolean;
  15299. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15300. markTextureDirty(): void;
  15301. /**
  15302. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15303. * 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.
  15304. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15305. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15306. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15307. * @returns The target texture that was bound to be written to.
  15308. */
  15309. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15310. /**
  15311. * If the post process is supported.
  15312. */
  15313. readonly isSupported: boolean;
  15314. /**
  15315. * The aspect ratio of the output texture.
  15316. */
  15317. readonly aspectRatio: number;
  15318. /**
  15319. * Get a value indicating if the post-process is ready to be used
  15320. * @returns true if the post-process is ready (shader is compiled)
  15321. */
  15322. isReady(): boolean;
  15323. /**
  15324. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15325. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15326. */
  15327. apply(): Nullable<Effect>;
  15328. private _disposeTextures;
  15329. /**
  15330. * Disposes the post process.
  15331. * @param camera The camera to dispose the post process on.
  15332. */
  15333. dispose(camera?: Camera): void;
  15334. }
  15335. }
  15336. declare module BABYLON {
  15337. /** @hidden */
  15338. export var kernelBlurVaryingDeclaration: {
  15339. name: string;
  15340. shader: string;
  15341. };
  15342. }
  15343. declare module BABYLON {
  15344. /** @hidden */
  15345. export var kernelBlurFragment: {
  15346. name: string;
  15347. shader: string;
  15348. };
  15349. }
  15350. declare module BABYLON {
  15351. /** @hidden */
  15352. export var kernelBlurFragment2: {
  15353. name: string;
  15354. shader: string;
  15355. };
  15356. }
  15357. declare module BABYLON {
  15358. /** @hidden */
  15359. export var kernelBlurPixelShader: {
  15360. name: string;
  15361. shader: string;
  15362. };
  15363. }
  15364. declare module BABYLON {
  15365. /** @hidden */
  15366. export var kernelBlurVertex: {
  15367. name: string;
  15368. shader: string;
  15369. };
  15370. }
  15371. declare module BABYLON {
  15372. /** @hidden */
  15373. export var kernelBlurVertexShader: {
  15374. name: string;
  15375. shader: string;
  15376. };
  15377. }
  15378. declare module BABYLON {
  15379. /**
  15380. * The Blur Post Process which blurs an image based on a kernel and direction.
  15381. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15382. */
  15383. export class BlurPostProcess extends PostProcess {
  15384. /** The direction in which to blur the image. */
  15385. direction: Vector2;
  15386. private blockCompilation;
  15387. protected _kernel: number;
  15388. protected _idealKernel: number;
  15389. protected _packedFloat: boolean;
  15390. private _staticDefines;
  15391. /**
  15392. * Sets the length in pixels of the blur sample region
  15393. */
  15394. /**
  15395. * Gets the length in pixels of the blur sample region
  15396. */
  15397. kernel: number;
  15398. /**
  15399. * Sets wether or not the blur needs to unpack/repack floats
  15400. */
  15401. /**
  15402. * Gets wether or not the blur is unpacking/repacking floats
  15403. */
  15404. packedFloat: boolean;
  15405. /**
  15406. * Creates a new instance BlurPostProcess
  15407. * @param name The name of the effect.
  15408. * @param direction The direction in which to blur the image.
  15409. * @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.
  15410. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15411. * @param camera The camera to apply the render pass to.
  15412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15413. * @param engine The engine which the post process will be applied. (default: current engine)
  15414. * @param reusable If the post process can be reused on the same frame. (default: false)
  15415. * @param textureType Type of textures used when performing the post process. (default: 0)
  15416. * @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)
  15417. */
  15418. constructor(name: string,
  15419. /** The direction in which to blur the image. */
  15420. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15421. /**
  15422. * Updates the effect with the current post process compile time values and recompiles the shader.
  15423. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15424. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15425. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15426. * @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
  15427. * @param onCompiled Called when the shader has been compiled.
  15428. * @param onError Called if there is an error when compiling a shader.
  15429. */
  15430. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15431. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15432. /**
  15433. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15434. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15435. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15436. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15437. * The gaps between physical kernels are compensated for in the weighting of the samples
  15438. * @param idealKernel Ideal blur kernel.
  15439. * @return Nearest best kernel.
  15440. */
  15441. protected _nearestBestKernel(idealKernel: number): number;
  15442. /**
  15443. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15444. * @param x The point on the Gaussian distribution to sample.
  15445. * @return the value of the Gaussian function at x.
  15446. */
  15447. protected _gaussianWeight(x: number): number;
  15448. /**
  15449. * Generates a string that can be used as a floating point number in GLSL.
  15450. * @param x Value to print.
  15451. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15452. * @return GLSL float string.
  15453. */
  15454. protected _glslFloat(x: number, decimalFigures?: number): string;
  15455. }
  15456. }
  15457. declare module BABYLON {
  15458. /**
  15459. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15460. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15461. * You can then easily use it as a reflectionTexture on a flat surface.
  15462. * In case the surface is not a plane, please consider relying on reflection probes.
  15463. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15464. */
  15465. export class MirrorTexture extends RenderTargetTexture {
  15466. private scene;
  15467. /**
  15468. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15469. * 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.
  15470. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15471. */
  15472. mirrorPlane: Plane;
  15473. /**
  15474. * Define the blur ratio used to blur the reflection if needed.
  15475. */
  15476. blurRatio: number;
  15477. /**
  15478. * Define the adaptive blur kernel used to blur the reflection if needed.
  15479. * This will autocompute the closest best match for the `blurKernel`
  15480. */
  15481. adaptiveBlurKernel: number;
  15482. /**
  15483. * Define the blur kernel used to blur the reflection if needed.
  15484. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15485. */
  15486. blurKernel: number;
  15487. /**
  15488. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15489. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15490. */
  15491. blurKernelX: number;
  15492. /**
  15493. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15494. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15495. */
  15496. blurKernelY: number;
  15497. private _autoComputeBlurKernel;
  15498. protected _onRatioRescale(): void;
  15499. private _updateGammaSpace;
  15500. private _imageProcessingConfigChangeObserver;
  15501. private _transformMatrix;
  15502. private _mirrorMatrix;
  15503. private _savedViewMatrix;
  15504. private _blurX;
  15505. private _blurY;
  15506. private _adaptiveBlurKernel;
  15507. private _blurKernelX;
  15508. private _blurKernelY;
  15509. private _blurRatio;
  15510. /**
  15511. * Instantiates a Mirror Texture.
  15512. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15513. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15514. * You can then easily use it as a reflectionTexture on a flat surface.
  15515. * In case the surface is not a plane, please consider relying on reflection probes.
  15516. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15517. * @param name
  15518. * @param size
  15519. * @param scene
  15520. * @param generateMipMaps
  15521. * @param type
  15522. * @param samplingMode
  15523. * @param generateDepthBuffer
  15524. */
  15525. constructor(name: string, size: number | {
  15526. width: number;
  15527. height: number;
  15528. } | {
  15529. ratio: number;
  15530. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15531. private _preparePostProcesses;
  15532. /**
  15533. * Clone the mirror texture.
  15534. * @returns the cloned texture
  15535. */
  15536. clone(): MirrorTexture;
  15537. /**
  15538. * Serialize the texture to a JSON representation you could use in Parse later on
  15539. * @returns the serialized JSON representation
  15540. */
  15541. serialize(): any;
  15542. /**
  15543. * Dispose the texture and release its associated resources.
  15544. */
  15545. dispose(): void;
  15546. }
  15547. }
  15548. declare module BABYLON {
  15549. /**
  15550. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15551. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15552. */
  15553. export class Texture extends BaseTexture {
  15554. /**
  15555. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15556. */
  15557. static SerializeBuffers: boolean;
  15558. /** @hidden */
  15559. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15560. /** @hidden */
  15561. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15562. /** @hidden */
  15563. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15564. /** nearest is mag = nearest and min = nearest and mip = linear */
  15565. static readonly NEAREST_SAMPLINGMODE: number;
  15566. /** nearest is mag = nearest and min = nearest and mip = linear */
  15567. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15569. static readonly BILINEAR_SAMPLINGMODE: number;
  15570. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15571. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15572. /** Trilinear is mag = linear and min = linear and mip = linear */
  15573. static readonly TRILINEAR_SAMPLINGMODE: number;
  15574. /** Trilinear is mag = linear and min = linear and mip = linear */
  15575. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15576. /** mag = nearest and min = nearest and mip = nearest */
  15577. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15578. /** mag = nearest and min = linear and mip = nearest */
  15579. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15580. /** mag = nearest and min = linear and mip = linear */
  15581. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15582. /** mag = nearest and min = linear and mip = none */
  15583. static readonly NEAREST_LINEAR: number;
  15584. /** mag = nearest and min = nearest and mip = none */
  15585. static readonly NEAREST_NEAREST: number;
  15586. /** mag = linear and min = nearest and mip = nearest */
  15587. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15588. /** mag = linear and min = nearest and mip = linear */
  15589. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15590. /** mag = linear and min = linear and mip = none */
  15591. static readonly LINEAR_LINEAR: number;
  15592. /** mag = linear and min = nearest and mip = none */
  15593. static readonly LINEAR_NEAREST: number;
  15594. /** Explicit coordinates mode */
  15595. static readonly EXPLICIT_MODE: number;
  15596. /** Spherical coordinates mode */
  15597. static readonly SPHERICAL_MODE: number;
  15598. /** Planar coordinates mode */
  15599. static readonly PLANAR_MODE: number;
  15600. /** Cubic coordinates mode */
  15601. static readonly CUBIC_MODE: number;
  15602. /** Projection coordinates mode */
  15603. static readonly PROJECTION_MODE: number;
  15604. /** Inverse Cubic coordinates mode */
  15605. static readonly SKYBOX_MODE: number;
  15606. /** Inverse Cubic coordinates mode */
  15607. static readonly INVCUBIC_MODE: number;
  15608. /** Equirectangular coordinates mode */
  15609. static readonly EQUIRECTANGULAR_MODE: number;
  15610. /** Equirectangular Fixed coordinates mode */
  15611. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15612. /** Equirectangular Fixed Mirrored coordinates mode */
  15613. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15614. /** Texture is not repeating outside of 0..1 UVs */
  15615. static readonly CLAMP_ADDRESSMODE: number;
  15616. /** Texture is repeating outside of 0..1 UVs */
  15617. static readonly WRAP_ADDRESSMODE: number;
  15618. /** Texture is repeating and mirrored */
  15619. static readonly MIRROR_ADDRESSMODE: number;
  15620. /**
  15621. * 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
  15622. */
  15623. static UseSerializedUrlIfAny: boolean;
  15624. /**
  15625. * Define the url of the texture.
  15626. */
  15627. url: Nullable<string>;
  15628. /**
  15629. * Define an offset on the texture to offset the u coordinates of the UVs
  15630. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15631. */
  15632. uOffset: number;
  15633. /**
  15634. * Define an offset on the texture to offset the v coordinates of the UVs
  15635. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15636. */
  15637. vOffset: number;
  15638. /**
  15639. * Define an offset on the texture to scale the u coordinates of the UVs
  15640. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15641. */
  15642. uScale: number;
  15643. /**
  15644. * Define an offset on the texture to scale the v coordinates of the UVs
  15645. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15646. */
  15647. vScale: number;
  15648. /**
  15649. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15650. * @see http://doc.babylonjs.com/how_to/more_materials
  15651. */
  15652. uAng: number;
  15653. /**
  15654. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15655. * @see http://doc.babylonjs.com/how_to/more_materials
  15656. */
  15657. vAng: number;
  15658. /**
  15659. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15660. * @see http://doc.babylonjs.com/how_to/more_materials
  15661. */
  15662. wAng: number;
  15663. /**
  15664. * Defines the center of rotation (U)
  15665. */
  15666. uRotationCenter: number;
  15667. /**
  15668. * Defines the center of rotation (V)
  15669. */
  15670. vRotationCenter: number;
  15671. /**
  15672. * Defines the center of rotation (W)
  15673. */
  15674. wRotationCenter: number;
  15675. /**
  15676. * Are mip maps generated for this texture or not.
  15677. */
  15678. readonly noMipmap: boolean;
  15679. /**
  15680. * List of inspectable custom properties (used by the Inspector)
  15681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15682. */
  15683. inspectableCustomProperties: Nullable<IInspectable[]>;
  15684. private _noMipmap;
  15685. /** @hidden */
  15686. _invertY: boolean;
  15687. private _rowGenerationMatrix;
  15688. private _cachedTextureMatrix;
  15689. private _projectionModeMatrix;
  15690. private _t0;
  15691. private _t1;
  15692. private _t2;
  15693. private _cachedUOffset;
  15694. private _cachedVOffset;
  15695. private _cachedUScale;
  15696. private _cachedVScale;
  15697. private _cachedUAng;
  15698. private _cachedVAng;
  15699. private _cachedWAng;
  15700. private _cachedProjectionMatrixId;
  15701. private _cachedCoordinatesMode;
  15702. /** @hidden */
  15703. protected _initialSamplingMode: number;
  15704. /** @hidden */
  15705. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15706. private _deleteBuffer;
  15707. protected _format: Nullable<number>;
  15708. private _delayedOnLoad;
  15709. private _delayedOnError;
  15710. /**
  15711. * Observable triggered once the texture has been loaded.
  15712. */
  15713. onLoadObservable: Observable<Texture>;
  15714. protected _isBlocking: boolean;
  15715. /**
  15716. * Is the texture preventing material to render while loading.
  15717. * If false, a default texture will be used instead of the loading one during the preparation step.
  15718. */
  15719. isBlocking: boolean;
  15720. /**
  15721. * Get the current sampling mode associated with the texture.
  15722. */
  15723. readonly samplingMode: number;
  15724. /**
  15725. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15726. */
  15727. readonly invertY: boolean;
  15728. /**
  15729. * Instantiates a new texture.
  15730. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15731. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15732. * @param url define the url of the picture to load as a texture
  15733. * @param scene define the scene or engine the texture will belong to
  15734. * @param noMipmap define if the texture will require mip maps or not
  15735. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15736. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15737. * @param onLoad define a callback triggered when the texture has been loaded
  15738. * @param onError define a callback triggered when an error occurred during the loading session
  15739. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15740. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15741. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15742. */
  15743. 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);
  15744. /**
  15745. * Update the url (and optional buffer) of this texture if url was null during construction.
  15746. * @param url the url of the texture
  15747. * @param buffer the buffer of the texture (defaults to null)
  15748. * @param onLoad callback called when the texture is loaded (defaults to null)
  15749. */
  15750. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15751. /**
  15752. * Finish the loading sequence of a texture flagged as delayed load.
  15753. * @hidden
  15754. */
  15755. delayLoad(): void;
  15756. private _prepareRowForTextureGeneration;
  15757. /**
  15758. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15759. * @returns the transform matrix of the texture.
  15760. */
  15761. getTextureMatrix(): Matrix;
  15762. /**
  15763. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15764. * @returns The reflection texture transform
  15765. */
  15766. getReflectionTextureMatrix(): Matrix;
  15767. /**
  15768. * Clones the texture.
  15769. * @returns the cloned texture
  15770. */
  15771. clone(): Texture;
  15772. /**
  15773. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15774. * @returns The JSON representation of the texture
  15775. */
  15776. serialize(): any;
  15777. /**
  15778. * Get the current class name of the texture useful for serialization or dynamic coding.
  15779. * @returns "Texture"
  15780. */
  15781. getClassName(): string;
  15782. /**
  15783. * Dispose the texture and release its associated resources.
  15784. */
  15785. dispose(): void;
  15786. /**
  15787. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15788. * @param parsedTexture Define the JSON representation of the texture
  15789. * @param scene Define the scene the parsed texture should be instantiated in
  15790. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15791. * @returns The parsed texture if successful
  15792. */
  15793. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15794. /**
  15795. * Creates a texture from its base 64 representation.
  15796. * @param data Define the base64 payload without the data: prefix
  15797. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15798. * @param scene Define the scene the texture should belong to
  15799. * @param noMipmap Forces the texture to not create mip map information if true
  15800. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15801. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15802. * @param onLoad define a callback triggered when the texture has been loaded
  15803. * @param onError define a callback triggered when an error occurred during the loading session
  15804. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15805. * @returns the created texture
  15806. */
  15807. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15808. /**
  15809. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15810. * @param data Define the base64 payload without the data: prefix
  15811. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15812. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15813. * @param scene Define the scene the texture should belong to
  15814. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15815. * @param noMipmap Forces the texture to not create mip map information if true
  15816. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15817. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15818. * @param onLoad define a callback triggered when the texture has been loaded
  15819. * @param onError define a callback triggered when an error occurred during the loading session
  15820. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15821. * @returns the created texture
  15822. */
  15823. 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;
  15824. }
  15825. }
  15826. declare module BABYLON {
  15827. /**
  15828. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15829. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15830. */
  15831. export class PostProcessManager {
  15832. private _scene;
  15833. private _indexBuffer;
  15834. private _vertexBuffers;
  15835. /**
  15836. * Creates a new instance PostProcess
  15837. * @param scene The scene that the post process is associated with.
  15838. */
  15839. constructor(scene: Scene);
  15840. private _prepareBuffers;
  15841. private _buildIndexBuffer;
  15842. /**
  15843. * Rebuilds the vertex buffers of the manager.
  15844. * @hidden
  15845. */
  15846. _rebuild(): void;
  15847. /**
  15848. * Prepares a frame to be run through a post process.
  15849. * @param sourceTexture The input texture to the post procesess. (default: null)
  15850. * @param postProcesses An array of post processes to be run. (default: null)
  15851. * @returns True if the post processes were able to be run.
  15852. * @hidden
  15853. */
  15854. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15855. /**
  15856. * Manually render a set of post processes to a texture.
  15857. * @param postProcesses An array of post processes to be run.
  15858. * @param targetTexture The target texture to render to.
  15859. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15860. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15861. * @param lodLevel defines which lod of the texture to render to
  15862. */
  15863. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15864. /**
  15865. * Finalize the result of the output of the postprocesses.
  15866. * @param doNotPresent If true the result will not be displayed to the screen.
  15867. * @param targetTexture The target texture to render to.
  15868. * @param faceIndex The index of the face to bind the target texture to.
  15869. * @param postProcesses The array of post processes to render.
  15870. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15871. * @hidden
  15872. */
  15873. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15874. /**
  15875. * Disposes of the post process manager.
  15876. */
  15877. dispose(): void;
  15878. }
  15879. }
  15880. declare module BABYLON {
  15881. /** Interface used by value gradients (color, factor, ...) */
  15882. export interface IValueGradient {
  15883. /**
  15884. * Gets or sets the gradient value (between 0 and 1)
  15885. */
  15886. gradient: number;
  15887. }
  15888. /** Class used to store color4 gradient */
  15889. export class ColorGradient implements IValueGradient {
  15890. /**
  15891. * Gets or sets the gradient value (between 0 and 1)
  15892. */
  15893. gradient: number;
  15894. /**
  15895. * Gets or sets first associated color
  15896. */
  15897. color1: Color4;
  15898. /**
  15899. * Gets or sets second associated color
  15900. */
  15901. color2?: Color4;
  15902. /**
  15903. * Will get a color picked randomly between color1 and color2.
  15904. * If color2 is undefined then color1 will be used
  15905. * @param result defines the target Color4 to store the result in
  15906. */
  15907. getColorToRef(result: Color4): void;
  15908. }
  15909. /** Class used to store color 3 gradient */
  15910. export class Color3Gradient implements IValueGradient {
  15911. /**
  15912. * Gets or sets the gradient value (between 0 and 1)
  15913. */
  15914. gradient: number;
  15915. /**
  15916. * Gets or sets the associated color
  15917. */
  15918. color: Color3;
  15919. }
  15920. /** Class used to store factor gradient */
  15921. export class FactorGradient implements IValueGradient {
  15922. /**
  15923. * Gets or sets the gradient value (between 0 and 1)
  15924. */
  15925. gradient: number;
  15926. /**
  15927. * Gets or sets first associated factor
  15928. */
  15929. factor1: number;
  15930. /**
  15931. * Gets or sets second associated factor
  15932. */
  15933. factor2?: number;
  15934. /**
  15935. * Will get a number picked randomly between factor1 and factor2.
  15936. * If factor2 is undefined then factor1 will be used
  15937. * @returns the picked number
  15938. */
  15939. getFactor(): number;
  15940. }
  15941. /**
  15942. * Helper used to simplify some generic gradient tasks
  15943. */
  15944. export class GradientHelper {
  15945. /**
  15946. * Gets the current gradient from an array of IValueGradient
  15947. * @param ratio defines the current ratio to get
  15948. * @param gradients defines the array of IValueGradient
  15949. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15950. */
  15951. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15952. }
  15953. }
  15954. declare module BABYLON {
  15955. interface AbstractScene {
  15956. /**
  15957. * The list of procedural textures added to the scene
  15958. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15959. */
  15960. proceduralTextures: Array<ProceduralTexture>;
  15961. }
  15962. /**
  15963. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15964. * in a given scene.
  15965. */
  15966. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15967. /**
  15968. * The component name helpfull to identify the component in the list of scene components.
  15969. */
  15970. readonly name: string;
  15971. /**
  15972. * The scene the component belongs to.
  15973. */
  15974. scene: Scene;
  15975. /**
  15976. * Creates a new instance of the component for the given scene
  15977. * @param scene Defines the scene to register the component in
  15978. */
  15979. constructor(scene: Scene);
  15980. /**
  15981. * Registers the component in a given scene
  15982. */
  15983. register(): void;
  15984. /**
  15985. * Rebuilds the elements related to this component in case of
  15986. * context lost for instance.
  15987. */
  15988. rebuild(): void;
  15989. /**
  15990. * Disposes the component and the associated ressources.
  15991. */
  15992. dispose(): void;
  15993. private _beforeClear;
  15994. }
  15995. }
  15996. declare module BABYLON {
  15997. interface Engine {
  15998. /**
  15999. * Creates a new render target cube texture
  16000. * @param size defines the size of the texture
  16001. * @param options defines the options used to create the texture
  16002. * @returns a new render target cube texture stored in an InternalTexture
  16003. */
  16004. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16005. }
  16006. }
  16007. declare module BABYLON {
  16008. /** @hidden */
  16009. export var proceduralVertexShader: {
  16010. name: string;
  16011. shader: string;
  16012. };
  16013. }
  16014. declare module BABYLON {
  16015. /**
  16016. * 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.
  16017. * This is the base class of any Procedural texture and contains most of the shareable code.
  16018. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16019. */
  16020. export class ProceduralTexture extends Texture {
  16021. isCube: boolean;
  16022. /**
  16023. * Define if the texture is enabled or not (disabled texture will not render)
  16024. */
  16025. isEnabled: boolean;
  16026. /**
  16027. * Define if the texture must be cleared before rendering (default is true)
  16028. */
  16029. autoClear: boolean;
  16030. /**
  16031. * Callback called when the texture is generated
  16032. */
  16033. onGenerated: () => void;
  16034. /**
  16035. * Event raised when the texture is generated
  16036. */
  16037. onGeneratedObservable: Observable<ProceduralTexture>;
  16038. /** @hidden */
  16039. _generateMipMaps: boolean;
  16040. /** @hidden **/
  16041. _effect: Effect;
  16042. /** @hidden */
  16043. _textures: {
  16044. [key: string]: Texture;
  16045. };
  16046. private _size;
  16047. private _currentRefreshId;
  16048. private _refreshRate;
  16049. private _vertexBuffers;
  16050. private _indexBuffer;
  16051. private _uniforms;
  16052. private _samplers;
  16053. private _fragment;
  16054. private _floats;
  16055. private _ints;
  16056. private _floatsArrays;
  16057. private _colors3;
  16058. private _colors4;
  16059. private _vectors2;
  16060. private _vectors3;
  16061. private _matrices;
  16062. private _fallbackTexture;
  16063. private _fallbackTextureUsed;
  16064. private _engine;
  16065. private _cachedDefines;
  16066. private _contentUpdateId;
  16067. private _contentData;
  16068. /**
  16069. * Instantiates a new procedural texture.
  16070. * 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.
  16071. * This is the base class of any Procedural texture and contains most of the shareable code.
  16072. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16073. * @param name Define the name of the texture
  16074. * @param size Define the size of the texture to create
  16075. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16076. * @param scene Define the scene the texture belongs to
  16077. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16078. * @param generateMipMaps Define if the texture should creates mip maps or not
  16079. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16080. */
  16081. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16082. /**
  16083. * The effect that is created when initializing the post process.
  16084. * @returns The created effect corresponding the the postprocess.
  16085. */
  16086. getEffect(): Effect;
  16087. /**
  16088. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16089. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16090. */
  16091. getContent(): Nullable<ArrayBufferView>;
  16092. private _createIndexBuffer;
  16093. /** @hidden */
  16094. _rebuild(): void;
  16095. /**
  16096. * Resets the texture in order to recreate its associated resources.
  16097. * This can be called in case of context loss
  16098. */
  16099. reset(): void;
  16100. protected _getDefines(): string;
  16101. /**
  16102. * Is the texture ready to be used ? (rendered at least once)
  16103. * @returns true if ready, otherwise, false.
  16104. */
  16105. isReady(): boolean;
  16106. /**
  16107. * Resets the refresh counter of the texture and start bak from scratch.
  16108. * Could be useful to regenerate the texture if it is setup to render only once.
  16109. */
  16110. resetRefreshCounter(): void;
  16111. /**
  16112. * Set the fragment shader to use in order to render the texture.
  16113. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16114. */
  16115. setFragment(fragment: any): void;
  16116. /**
  16117. * Define the refresh rate of the texture or the rendering frequency.
  16118. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16119. */
  16120. refreshRate: number;
  16121. /** @hidden */
  16122. _shouldRender(): boolean;
  16123. /**
  16124. * Get the size the texture is rendering at.
  16125. * @returns the size (texture is always squared)
  16126. */
  16127. getRenderSize(): number;
  16128. /**
  16129. * Resize the texture to new value.
  16130. * @param size Define the new size the texture should have
  16131. * @param generateMipMaps Define whether the new texture should create mip maps
  16132. */
  16133. resize(size: number, generateMipMaps: boolean): void;
  16134. private _checkUniform;
  16135. /**
  16136. * Set a texture in the shader program used to render.
  16137. * @param name Define the name of the uniform samplers as defined in the shader
  16138. * @param texture Define the texture to bind to this sampler
  16139. * @return the texture itself allowing "fluent" like uniform updates
  16140. */
  16141. setTexture(name: string, texture: Texture): ProceduralTexture;
  16142. /**
  16143. * Set a float in the shader.
  16144. * @param name Define the name of the uniform as defined in the shader
  16145. * @param value Define the value to give to the uniform
  16146. * @return the texture itself allowing "fluent" like uniform updates
  16147. */
  16148. setFloat(name: string, value: number): ProceduralTexture;
  16149. /**
  16150. * Set a int in the shader.
  16151. * @param name Define the name of the uniform as defined in the shader
  16152. * @param value Define the value to give to the uniform
  16153. * @return the texture itself allowing "fluent" like uniform updates
  16154. */
  16155. setInt(name: string, value: number): ProceduralTexture;
  16156. /**
  16157. * Set an array of floats in the shader.
  16158. * @param name Define the name of the uniform as defined in the shader
  16159. * @param value Define the value to give to the uniform
  16160. * @return the texture itself allowing "fluent" like uniform updates
  16161. */
  16162. setFloats(name: string, value: number[]): ProceduralTexture;
  16163. /**
  16164. * Set a vec3 in the shader from a Color3.
  16165. * @param name Define the name of the uniform as defined in the shader
  16166. * @param value Define the value to give to the uniform
  16167. * @return the texture itself allowing "fluent" like uniform updates
  16168. */
  16169. setColor3(name: string, value: Color3): ProceduralTexture;
  16170. /**
  16171. * Set a vec4 in the shader from a Color4.
  16172. * @param name Define the name of the uniform as defined in the shader
  16173. * @param value Define the value to give to the uniform
  16174. * @return the texture itself allowing "fluent" like uniform updates
  16175. */
  16176. setColor4(name: string, value: Color4): ProceduralTexture;
  16177. /**
  16178. * Set a vec2 in the shader from a Vector2.
  16179. * @param name Define the name of the uniform as defined in the shader
  16180. * @param value Define the value to give to the uniform
  16181. * @return the texture itself allowing "fluent" like uniform updates
  16182. */
  16183. setVector2(name: string, value: Vector2): ProceduralTexture;
  16184. /**
  16185. * Set a vec3 in the shader from a Vector3.
  16186. * @param name Define the name of the uniform as defined in the shader
  16187. * @param value Define the value to give to the uniform
  16188. * @return the texture itself allowing "fluent" like uniform updates
  16189. */
  16190. setVector3(name: string, value: Vector3): ProceduralTexture;
  16191. /**
  16192. * Set a mat4 in the shader from a MAtrix.
  16193. * @param name Define the name of the uniform as defined in the shader
  16194. * @param value Define the value to give to the uniform
  16195. * @return the texture itself allowing "fluent" like uniform updates
  16196. */
  16197. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16198. /**
  16199. * Render the texture to its associated render target.
  16200. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16201. */
  16202. render(useCameraPostProcess?: boolean): void;
  16203. /**
  16204. * Clone the texture.
  16205. * @returns the cloned texture
  16206. */
  16207. clone(): ProceduralTexture;
  16208. /**
  16209. * Dispose the texture and release its asoociated resources.
  16210. */
  16211. dispose(): void;
  16212. }
  16213. }
  16214. declare module BABYLON {
  16215. /**
  16216. * This represents the base class for particle system in Babylon.
  16217. * 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.
  16218. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16219. * @example https://doc.babylonjs.com/babylon101/particles
  16220. */
  16221. export class BaseParticleSystem {
  16222. /**
  16223. * Source color is added to the destination color without alpha affecting the result
  16224. */
  16225. static BLENDMODE_ONEONE: number;
  16226. /**
  16227. * Blend current color and particle color using particle’s alpha
  16228. */
  16229. static BLENDMODE_STANDARD: number;
  16230. /**
  16231. * Add current color and particle color multiplied by particle’s alpha
  16232. */
  16233. static BLENDMODE_ADD: number;
  16234. /**
  16235. * Multiply current color with particle color
  16236. */
  16237. static BLENDMODE_MULTIPLY: number;
  16238. /**
  16239. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16240. */
  16241. static BLENDMODE_MULTIPLYADD: number;
  16242. /**
  16243. * List of animations used by the particle system.
  16244. */
  16245. animations: Animation[];
  16246. /**
  16247. * The id of the Particle system.
  16248. */
  16249. id: string;
  16250. /**
  16251. * The friendly name of the Particle system.
  16252. */
  16253. name: string;
  16254. /**
  16255. * The rendering group used by the Particle system to chose when to render.
  16256. */
  16257. renderingGroupId: number;
  16258. /**
  16259. * The emitter represents the Mesh or position we are attaching the particle system to.
  16260. */
  16261. emitter: Nullable<AbstractMesh | Vector3>;
  16262. /**
  16263. * The maximum number of particles to emit per frame
  16264. */
  16265. emitRate: number;
  16266. /**
  16267. * If you want to launch only a few particles at once, that can be done, as well.
  16268. */
  16269. manualEmitCount: number;
  16270. /**
  16271. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16272. */
  16273. updateSpeed: number;
  16274. /**
  16275. * The amount of time the particle system is running (depends of the overall update speed).
  16276. */
  16277. targetStopDuration: number;
  16278. /**
  16279. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16280. */
  16281. disposeOnStop: boolean;
  16282. /**
  16283. * Minimum power of emitting particles.
  16284. */
  16285. minEmitPower: number;
  16286. /**
  16287. * Maximum power of emitting particles.
  16288. */
  16289. maxEmitPower: number;
  16290. /**
  16291. * Minimum life time of emitting particles.
  16292. */
  16293. minLifeTime: number;
  16294. /**
  16295. * Maximum life time of emitting particles.
  16296. */
  16297. maxLifeTime: number;
  16298. /**
  16299. * Minimum Size of emitting particles.
  16300. */
  16301. minSize: number;
  16302. /**
  16303. * Maximum Size of emitting particles.
  16304. */
  16305. maxSize: number;
  16306. /**
  16307. * Minimum scale of emitting particles on X axis.
  16308. */
  16309. minScaleX: number;
  16310. /**
  16311. * Maximum scale of emitting particles on X axis.
  16312. */
  16313. maxScaleX: number;
  16314. /**
  16315. * Minimum scale of emitting particles on Y axis.
  16316. */
  16317. minScaleY: number;
  16318. /**
  16319. * Maximum scale of emitting particles on Y axis.
  16320. */
  16321. maxScaleY: number;
  16322. /**
  16323. * Gets or sets the minimal initial rotation in radians.
  16324. */
  16325. minInitialRotation: number;
  16326. /**
  16327. * Gets or sets the maximal initial rotation in radians.
  16328. */
  16329. maxInitialRotation: number;
  16330. /**
  16331. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16332. */
  16333. minAngularSpeed: number;
  16334. /**
  16335. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16336. */
  16337. maxAngularSpeed: number;
  16338. /**
  16339. * The texture used to render each particle. (this can be a spritesheet)
  16340. */
  16341. particleTexture: Nullable<Texture>;
  16342. /**
  16343. * The layer mask we are rendering the particles through.
  16344. */
  16345. layerMask: number;
  16346. /**
  16347. * This can help using your own shader to render the particle system.
  16348. * The according effect will be created
  16349. */
  16350. customShader: any;
  16351. /**
  16352. * By default particle system starts as soon as they are created. This prevents the
  16353. * automatic start to happen and let you decide when to start emitting particles.
  16354. */
  16355. preventAutoStart: boolean;
  16356. private _noiseTexture;
  16357. /**
  16358. * Gets or sets a texture used to add random noise to particle positions
  16359. */
  16360. noiseTexture: Nullable<ProceduralTexture>;
  16361. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16362. noiseStrength: Vector3;
  16363. /**
  16364. * Callback triggered when the particle animation is ending.
  16365. */
  16366. onAnimationEnd: Nullable<() => void>;
  16367. /**
  16368. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16369. */
  16370. blendMode: number;
  16371. /**
  16372. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16373. * to override the particles.
  16374. */
  16375. forceDepthWrite: boolean;
  16376. /** 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 */
  16377. preWarmCycles: number;
  16378. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16379. preWarmStepOffset: number;
  16380. /**
  16381. * 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)
  16382. */
  16383. spriteCellChangeSpeed: number;
  16384. /**
  16385. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16386. */
  16387. startSpriteCellID: number;
  16388. /**
  16389. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16390. */
  16391. endSpriteCellID: number;
  16392. /**
  16393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16394. */
  16395. spriteCellWidth: number;
  16396. /**
  16397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16398. */
  16399. spriteCellHeight: number;
  16400. /**
  16401. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16402. */
  16403. spriteRandomStartCell: boolean;
  16404. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16405. translationPivot: Vector2;
  16406. /** @hidden */
  16407. protected _isAnimationSheetEnabled: boolean;
  16408. /**
  16409. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16410. */
  16411. beginAnimationOnStart: boolean;
  16412. /**
  16413. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16414. */
  16415. beginAnimationFrom: number;
  16416. /**
  16417. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16418. */
  16419. beginAnimationTo: number;
  16420. /**
  16421. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16422. */
  16423. beginAnimationLoop: boolean;
  16424. /**
  16425. * Gets or sets a world offset applied to all particles
  16426. */
  16427. worldOffset: Vector3;
  16428. /**
  16429. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16430. */
  16431. isAnimationSheetEnabled: boolean;
  16432. /**
  16433. * Get hosting scene
  16434. * @returns the scene
  16435. */
  16436. getScene(): Scene;
  16437. /**
  16438. * You can use gravity if you want to give an orientation to your particles.
  16439. */
  16440. gravity: Vector3;
  16441. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16442. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16443. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16444. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16445. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16446. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16447. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16448. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16449. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16450. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16451. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16452. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16453. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16454. /**
  16455. * Defines the delay in milliseconds before starting the system (0 by default)
  16456. */
  16457. startDelay: number;
  16458. /**
  16459. * Gets the current list of drag gradients.
  16460. * You must use addDragGradient and removeDragGradient to udpate this list
  16461. * @returns the list of drag gradients
  16462. */
  16463. getDragGradients(): Nullable<Array<FactorGradient>>;
  16464. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16465. limitVelocityDamping: number;
  16466. /**
  16467. * Gets the current list of limit velocity gradients.
  16468. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16469. * @returns the list of limit velocity gradients
  16470. */
  16471. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16472. /**
  16473. * Gets the current list of color gradients.
  16474. * You must use addColorGradient and removeColorGradient to udpate this list
  16475. * @returns the list of color gradients
  16476. */
  16477. getColorGradients(): Nullable<Array<ColorGradient>>;
  16478. /**
  16479. * Gets the current list of size gradients.
  16480. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16481. * @returns the list of size gradients
  16482. */
  16483. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16484. /**
  16485. * Gets the current list of color remap gradients.
  16486. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16487. * @returns the list of color remap gradients
  16488. */
  16489. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16490. /**
  16491. * Gets the current list of alpha remap gradients.
  16492. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16493. * @returns the list of alpha remap gradients
  16494. */
  16495. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16496. /**
  16497. * Gets the current list of life time gradients.
  16498. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16499. * @returns the list of life time gradients
  16500. */
  16501. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16502. /**
  16503. * Gets the current list of angular speed gradients.
  16504. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16505. * @returns the list of angular speed gradients
  16506. */
  16507. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16508. /**
  16509. * Gets the current list of velocity gradients.
  16510. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16511. * @returns the list of velocity gradients
  16512. */
  16513. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16514. /**
  16515. * Gets the current list of start size gradients.
  16516. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16517. * @returns the list of start size gradients
  16518. */
  16519. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16520. /**
  16521. * Gets the current list of emit rate gradients.
  16522. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16523. * @returns the list of emit rate gradients
  16524. */
  16525. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16526. /**
  16527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16529. */
  16530. direction1: Vector3;
  16531. /**
  16532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16533. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16534. */
  16535. direction2: Vector3;
  16536. /**
  16537. * 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.
  16538. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16539. */
  16540. minEmitBox: Vector3;
  16541. /**
  16542. * 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.
  16543. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16544. */
  16545. maxEmitBox: Vector3;
  16546. /**
  16547. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16548. */
  16549. color1: Color4;
  16550. /**
  16551. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16552. */
  16553. color2: Color4;
  16554. /**
  16555. * Color the particle will have at the end of its lifetime
  16556. */
  16557. colorDead: Color4;
  16558. /**
  16559. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16560. */
  16561. textureMask: Color4;
  16562. /**
  16563. * The particle emitter type defines the emitter used by the particle system.
  16564. * It can be for example box, sphere, or cone...
  16565. */
  16566. particleEmitterType: IParticleEmitterType;
  16567. /** @hidden */
  16568. _isSubEmitter: boolean;
  16569. /**
  16570. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16571. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16572. */
  16573. billboardMode: number;
  16574. protected _isBillboardBased: boolean;
  16575. /**
  16576. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16577. */
  16578. isBillboardBased: boolean;
  16579. /**
  16580. * The scene the particle system belongs to.
  16581. */
  16582. protected _scene: Scene;
  16583. /**
  16584. * Local cache of defines for image processing.
  16585. */
  16586. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16587. /**
  16588. * Default configuration related to image processing available in the standard Material.
  16589. */
  16590. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16591. /**
  16592. * Gets the image processing configuration used either in this material.
  16593. */
  16594. /**
  16595. * Sets the Default image processing configuration used either in the this material.
  16596. *
  16597. * If sets to null, the scene one is in use.
  16598. */
  16599. imageProcessingConfiguration: ImageProcessingConfiguration;
  16600. /**
  16601. * Attaches a new image processing configuration to the Standard Material.
  16602. * @param configuration
  16603. */
  16604. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16605. /** @hidden */
  16606. protected _reset(): void;
  16607. /** @hidden */
  16608. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16609. /**
  16610. * Instantiates a particle system.
  16611. * 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.
  16612. * @param name The name of the particle system
  16613. */
  16614. constructor(name: string);
  16615. /**
  16616. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16617. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16618. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16619. * @returns the emitter
  16620. */
  16621. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16622. /**
  16623. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16624. * @param radius The radius of the hemisphere to emit from
  16625. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16626. * @returns the emitter
  16627. */
  16628. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16629. /**
  16630. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16631. * @param radius The radius of the sphere to emit from
  16632. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16633. * @returns the emitter
  16634. */
  16635. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16636. /**
  16637. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16638. * @param radius The radius of the sphere to emit from
  16639. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16640. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16641. * @returns the emitter
  16642. */
  16643. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16644. /**
  16645. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16646. * @param radius The radius of the emission cylinder
  16647. * @param height The height of the emission cylinder
  16648. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16649. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16650. * @returns the emitter
  16651. */
  16652. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16653. /**
  16654. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16655. * @param radius The radius of the cylinder to emit from
  16656. * @param height The height of the emission cylinder
  16657. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16658. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16659. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16660. * @returns the emitter
  16661. */
  16662. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16663. /**
  16664. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16665. * @param radius The radius of the cone to emit from
  16666. * @param angle The base angle of the cone
  16667. * @returns the emitter
  16668. */
  16669. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16670. /**
  16671. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16672. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16673. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16674. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16675. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16676. * @returns the emitter
  16677. */
  16678. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16679. }
  16680. }
  16681. declare module BABYLON {
  16682. /**
  16683. * Type of sub emitter
  16684. */
  16685. export enum SubEmitterType {
  16686. /**
  16687. * Attached to the particle over it's lifetime
  16688. */
  16689. ATTACHED = 0,
  16690. /**
  16691. * Created when the particle dies
  16692. */
  16693. END = 1
  16694. }
  16695. /**
  16696. * Sub emitter class used to emit particles from an existing particle
  16697. */
  16698. export class SubEmitter {
  16699. /**
  16700. * the particle system to be used by the sub emitter
  16701. */
  16702. particleSystem: ParticleSystem;
  16703. /**
  16704. * Type of the submitter (Default: END)
  16705. */
  16706. type: SubEmitterType;
  16707. /**
  16708. * 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)
  16709. * Note: This only is supported when using an emitter of type Mesh
  16710. */
  16711. inheritDirection: boolean;
  16712. /**
  16713. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16714. */
  16715. inheritedVelocityAmount: number;
  16716. /**
  16717. * Creates a sub emitter
  16718. * @param particleSystem the particle system to be used by the sub emitter
  16719. */
  16720. constructor(
  16721. /**
  16722. * the particle system to be used by the sub emitter
  16723. */
  16724. particleSystem: ParticleSystem);
  16725. /**
  16726. * Clones the sub emitter
  16727. * @returns the cloned sub emitter
  16728. */
  16729. clone(): SubEmitter;
  16730. /**
  16731. * Serialize current object to a JSON object
  16732. * @returns the serialized object
  16733. */
  16734. serialize(): any;
  16735. /** @hidden */
  16736. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16737. /**
  16738. * Creates a new SubEmitter from a serialized JSON version
  16739. * @param serializationObject defines the JSON object to read from
  16740. * @param scene defines the hosting scene
  16741. * @param rootUrl defines the rootUrl for data loading
  16742. * @returns a new SubEmitter
  16743. */
  16744. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16745. /** Release associated resources */
  16746. dispose(): void;
  16747. }
  16748. }
  16749. declare module BABYLON {
  16750. /** @hidden */
  16751. export var clipPlaneFragmentDeclaration: {
  16752. name: string;
  16753. shader: string;
  16754. };
  16755. }
  16756. declare module BABYLON {
  16757. /** @hidden */
  16758. export var imageProcessingDeclaration: {
  16759. name: string;
  16760. shader: string;
  16761. };
  16762. }
  16763. declare module BABYLON {
  16764. /** @hidden */
  16765. export var imageProcessingFunctions: {
  16766. name: string;
  16767. shader: string;
  16768. };
  16769. }
  16770. declare module BABYLON {
  16771. /** @hidden */
  16772. export var clipPlaneFragment: {
  16773. name: string;
  16774. shader: string;
  16775. };
  16776. }
  16777. declare module BABYLON {
  16778. /** @hidden */
  16779. export var particlesPixelShader: {
  16780. name: string;
  16781. shader: string;
  16782. };
  16783. }
  16784. declare module BABYLON {
  16785. /** @hidden */
  16786. export var clipPlaneVertexDeclaration: {
  16787. name: string;
  16788. shader: string;
  16789. };
  16790. }
  16791. declare module BABYLON {
  16792. /** @hidden */
  16793. export var clipPlaneVertex: {
  16794. name: string;
  16795. shader: string;
  16796. };
  16797. }
  16798. declare module BABYLON {
  16799. /** @hidden */
  16800. export var particlesVertexShader: {
  16801. name: string;
  16802. shader: string;
  16803. };
  16804. }
  16805. declare module BABYLON {
  16806. /**
  16807. * This represents a particle system in Babylon.
  16808. * 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.
  16809. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16810. * @example https://doc.babylonjs.com/babylon101/particles
  16811. */
  16812. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16813. /**
  16814. * Billboard mode will only apply to Y axis
  16815. */
  16816. static readonly BILLBOARDMODE_Y: number;
  16817. /**
  16818. * Billboard mode will apply to all axes
  16819. */
  16820. static readonly BILLBOARDMODE_ALL: number;
  16821. /**
  16822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16823. */
  16824. static readonly BILLBOARDMODE_STRETCHED: number;
  16825. /**
  16826. * This function can be defined to provide custom update for active particles.
  16827. * This function will be called instead of regular update (age, position, color, etc.).
  16828. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16829. */
  16830. updateFunction: (particles: Particle[]) => void;
  16831. private _emitterWorldMatrix;
  16832. /**
  16833. * This function can be defined to specify initial direction for every new particle.
  16834. * It by default use the emitterType defined function
  16835. */
  16836. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16837. /**
  16838. * This function can be defined to specify initial position for every new particle.
  16839. * It by default use the emitterType defined function
  16840. */
  16841. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16842. /**
  16843. * @hidden
  16844. */
  16845. _inheritedVelocityOffset: Vector3;
  16846. /**
  16847. * An event triggered when the system is disposed
  16848. */
  16849. onDisposeObservable: Observable<ParticleSystem>;
  16850. private _onDisposeObserver;
  16851. /**
  16852. * Sets a callback that will be triggered when the system is disposed
  16853. */
  16854. onDispose: () => void;
  16855. private _particles;
  16856. private _epsilon;
  16857. private _capacity;
  16858. private _stockParticles;
  16859. private _newPartsExcess;
  16860. private _vertexData;
  16861. private _vertexBuffer;
  16862. private _vertexBuffers;
  16863. private _spriteBuffer;
  16864. private _indexBuffer;
  16865. private _effect;
  16866. private _customEffect;
  16867. private _cachedDefines;
  16868. private _scaledColorStep;
  16869. private _colorDiff;
  16870. private _scaledDirection;
  16871. private _scaledGravity;
  16872. private _currentRenderId;
  16873. private _alive;
  16874. private _useInstancing;
  16875. private _started;
  16876. private _stopped;
  16877. private _actualFrame;
  16878. private _scaledUpdateSpeed;
  16879. private _vertexBufferSize;
  16880. /** @hidden */
  16881. _currentEmitRateGradient: Nullable<FactorGradient>;
  16882. /** @hidden */
  16883. _currentEmitRate1: number;
  16884. /** @hidden */
  16885. _currentEmitRate2: number;
  16886. /** @hidden */
  16887. _currentStartSizeGradient: Nullable<FactorGradient>;
  16888. /** @hidden */
  16889. _currentStartSize1: number;
  16890. /** @hidden */
  16891. _currentStartSize2: number;
  16892. private readonly _rawTextureWidth;
  16893. private _rampGradientsTexture;
  16894. private _useRampGradients;
  16895. /** Gets or sets a boolean indicating that ramp gradients must be used
  16896. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16897. */
  16898. useRampGradients: boolean;
  16899. /**
  16900. * 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.
  16901. * 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: [])
  16902. */
  16903. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16904. private _subEmitters;
  16905. /**
  16906. * @hidden
  16907. * If the particle systems emitter should be disposed when the particle system is disposed
  16908. */
  16909. _disposeEmitterOnDispose: boolean;
  16910. /**
  16911. * The current active Sub-systems, this property is used by the root particle system only.
  16912. */
  16913. activeSubSystems: Array<ParticleSystem>;
  16914. private _rootParticleSystem;
  16915. /**
  16916. * Gets the current list of active particles
  16917. */
  16918. readonly particles: Particle[];
  16919. /**
  16920. * Returns the string "ParticleSystem"
  16921. * @returns a string containing the class name
  16922. */
  16923. getClassName(): string;
  16924. /**
  16925. * Instantiates a particle system.
  16926. * 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.
  16927. * @param name The name of the particle system
  16928. * @param capacity The max number of particles alive at the same time
  16929. * @param scene The scene the particle system belongs to
  16930. * @param customEffect a custom effect used to change the way particles are rendered by default
  16931. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16932. * @param epsilon Offset used to render the particles
  16933. */
  16934. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16935. private _addFactorGradient;
  16936. private _removeFactorGradient;
  16937. /**
  16938. * Adds a new life time gradient
  16939. * @param gradient defines the gradient to use (between 0 and 1)
  16940. * @param factor defines the life time factor to affect to the specified gradient
  16941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16942. * @returns the current particle system
  16943. */
  16944. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16945. /**
  16946. * Remove a specific life time gradient
  16947. * @param gradient defines the gradient to remove
  16948. * @returns the current particle system
  16949. */
  16950. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16951. /**
  16952. * Adds a new size gradient
  16953. * @param gradient defines the gradient to use (between 0 and 1)
  16954. * @param factor defines the size factor to affect to the specified gradient
  16955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16956. * @returns the current particle system
  16957. */
  16958. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16959. /**
  16960. * Remove a specific size gradient
  16961. * @param gradient defines the gradient to remove
  16962. * @returns the current particle system
  16963. */
  16964. removeSizeGradient(gradient: number): IParticleSystem;
  16965. /**
  16966. * Adds a new color remap gradient
  16967. * @param gradient defines the gradient to use (between 0 and 1)
  16968. * @param min defines the color remap minimal range
  16969. * @param max defines the color remap maximal range
  16970. * @returns the current particle system
  16971. */
  16972. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16973. /**
  16974. * Remove a specific color remap gradient
  16975. * @param gradient defines the gradient to remove
  16976. * @returns the current particle system
  16977. */
  16978. removeColorRemapGradient(gradient: number): IParticleSystem;
  16979. /**
  16980. * Adds a new alpha remap gradient
  16981. * @param gradient defines the gradient to use (between 0 and 1)
  16982. * @param min defines the alpha remap minimal range
  16983. * @param max defines the alpha remap maximal range
  16984. * @returns the current particle system
  16985. */
  16986. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16987. /**
  16988. * Remove a specific alpha remap gradient
  16989. * @param gradient defines the gradient to remove
  16990. * @returns the current particle system
  16991. */
  16992. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16993. /**
  16994. * Adds a new angular speed gradient
  16995. * @param gradient defines the gradient to use (between 0 and 1)
  16996. * @param factor defines the angular speed to affect to the specified gradient
  16997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16998. * @returns the current particle system
  16999. */
  17000. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17001. /**
  17002. * Remove a specific angular speed gradient
  17003. * @param gradient defines the gradient to remove
  17004. * @returns the current particle system
  17005. */
  17006. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17007. /**
  17008. * Adds a new velocity gradient
  17009. * @param gradient defines the gradient to use (between 0 and 1)
  17010. * @param factor defines the velocity to affect to the specified gradient
  17011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17012. * @returns the current particle system
  17013. */
  17014. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17015. /**
  17016. * Remove a specific velocity gradient
  17017. * @param gradient defines the gradient to remove
  17018. * @returns the current particle system
  17019. */
  17020. removeVelocityGradient(gradient: number): IParticleSystem;
  17021. /**
  17022. * Adds a new limit velocity gradient
  17023. * @param gradient defines the gradient to use (between 0 and 1)
  17024. * @param factor defines the limit velocity value to affect to the specified gradient
  17025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17026. * @returns the current particle system
  17027. */
  17028. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17029. /**
  17030. * Remove a specific limit velocity gradient
  17031. * @param gradient defines the gradient to remove
  17032. * @returns the current particle system
  17033. */
  17034. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17035. /**
  17036. * Adds a new drag gradient
  17037. * @param gradient defines the gradient to use (between 0 and 1)
  17038. * @param factor defines the drag value to affect to the specified gradient
  17039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17040. * @returns the current particle system
  17041. */
  17042. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17043. /**
  17044. * Remove a specific drag gradient
  17045. * @param gradient defines the gradient to remove
  17046. * @returns the current particle system
  17047. */
  17048. removeDragGradient(gradient: number): IParticleSystem;
  17049. /**
  17050. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17051. * @param gradient defines the gradient to use (between 0 and 1)
  17052. * @param factor defines the emit rate value to affect to the specified gradient
  17053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17054. * @returns the current particle system
  17055. */
  17056. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17057. /**
  17058. * Remove a specific emit rate gradient
  17059. * @param gradient defines the gradient to remove
  17060. * @returns the current particle system
  17061. */
  17062. removeEmitRateGradient(gradient: number): IParticleSystem;
  17063. /**
  17064. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17065. * @param gradient defines the gradient to use (between 0 and 1)
  17066. * @param factor defines the start size value to affect to the specified gradient
  17067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17068. * @returns the current particle system
  17069. */
  17070. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17071. /**
  17072. * Remove a specific start size gradient
  17073. * @param gradient defines the gradient to remove
  17074. * @returns the current particle system
  17075. */
  17076. removeStartSizeGradient(gradient: number): IParticleSystem;
  17077. private _createRampGradientTexture;
  17078. /**
  17079. * Gets the current list of ramp gradients.
  17080. * You must use addRampGradient and removeRampGradient to udpate this list
  17081. * @returns the list of ramp gradients
  17082. */
  17083. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17084. /**
  17085. * Adds a new ramp gradient used to remap particle colors
  17086. * @param gradient defines the gradient to use (between 0 and 1)
  17087. * @param color defines the color to affect to the specified gradient
  17088. * @returns the current particle system
  17089. */
  17090. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17091. /**
  17092. * Remove a specific ramp gradient
  17093. * @param gradient defines the gradient to remove
  17094. * @returns the current particle system
  17095. */
  17096. removeRampGradient(gradient: number): ParticleSystem;
  17097. /**
  17098. * Adds a new color gradient
  17099. * @param gradient defines the gradient to use (between 0 and 1)
  17100. * @param color1 defines the color to affect to the specified gradient
  17101. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17102. * @returns this particle system
  17103. */
  17104. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17105. /**
  17106. * Remove a specific color gradient
  17107. * @param gradient defines the gradient to remove
  17108. * @returns this particle system
  17109. */
  17110. removeColorGradient(gradient: number): IParticleSystem;
  17111. private _fetchR;
  17112. protected _reset(): void;
  17113. private _resetEffect;
  17114. private _createVertexBuffers;
  17115. private _createIndexBuffer;
  17116. /**
  17117. * Gets the maximum number of particles active at the same time.
  17118. * @returns The max number of active particles.
  17119. */
  17120. getCapacity(): number;
  17121. /**
  17122. * Gets whether there are still active particles in the system.
  17123. * @returns True if it is alive, otherwise false.
  17124. */
  17125. isAlive(): boolean;
  17126. /**
  17127. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17128. * @returns True if it has been started, otherwise false.
  17129. */
  17130. isStarted(): boolean;
  17131. private _prepareSubEmitterInternalArray;
  17132. /**
  17133. * Starts the particle system and begins to emit
  17134. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17135. */
  17136. start(delay?: number): void;
  17137. /**
  17138. * Stops the particle system.
  17139. * @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.
  17140. */
  17141. stop(stopSubEmitters?: boolean): void;
  17142. /**
  17143. * Remove all active particles
  17144. */
  17145. reset(): void;
  17146. /**
  17147. * @hidden (for internal use only)
  17148. */
  17149. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17150. /**
  17151. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17152. * Its lifetime will start back at 0.
  17153. */
  17154. recycleParticle: (particle: Particle) => void;
  17155. private _stopSubEmitters;
  17156. private _createParticle;
  17157. private _removeFromRoot;
  17158. private _emitFromParticle;
  17159. private _update;
  17160. /** @hidden */
  17161. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17162. /** @hidden */
  17163. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17164. /** @hidden */
  17165. private _getEffect;
  17166. /**
  17167. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17168. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17169. */
  17170. animate(preWarmOnly?: boolean): void;
  17171. private _appendParticleVertices;
  17172. /**
  17173. * Rebuilds the particle system.
  17174. */
  17175. rebuild(): void;
  17176. /**
  17177. * Is this system ready to be used/rendered
  17178. * @return true if the system is ready
  17179. */
  17180. isReady(): boolean;
  17181. private _render;
  17182. /**
  17183. * Renders the particle system in its current state.
  17184. * @returns the current number of particles
  17185. */
  17186. render(): number;
  17187. /**
  17188. * Disposes the particle system and free the associated resources
  17189. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17190. */
  17191. dispose(disposeTexture?: boolean): void;
  17192. /**
  17193. * Clones the particle system.
  17194. * @param name The name of the cloned object
  17195. * @param newEmitter The new emitter to use
  17196. * @returns the cloned particle system
  17197. */
  17198. clone(name: string, newEmitter: any): ParticleSystem;
  17199. /**
  17200. * Serializes the particle system to a JSON object.
  17201. * @returns the JSON object
  17202. */
  17203. serialize(): any;
  17204. /** @hidden */
  17205. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17206. /** @hidden */
  17207. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17208. /**
  17209. * Parses a JSON object to create a particle system.
  17210. * @param parsedParticleSystem The JSON object to parse
  17211. * @param scene The scene to create the particle system in
  17212. * @param rootUrl The root url to use to load external dependencies like texture
  17213. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17214. * @returns the Parsed particle system
  17215. */
  17216. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17217. }
  17218. }
  17219. declare module BABYLON {
  17220. /**
  17221. * A particle represents one of the element emitted by a particle system.
  17222. * This is mainly define by its coordinates, direction, velocity and age.
  17223. */
  17224. export class Particle {
  17225. /**
  17226. * The particle system the particle belongs to.
  17227. */
  17228. particleSystem: ParticleSystem;
  17229. private static _Count;
  17230. /**
  17231. * Unique ID of the particle
  17232. */
  17233. id: number;
  17234. /**
  17235. * The world position of the particle in the scene.
  17236. */
  17237. position: Vector3;
  17238. /**
  17239. * The world direction of the particle in the scene.
  17240. */
  17241. direction: Vector3;
  17242. /**
  17243. * The color of the particle.
  17244. */
  17245. color: Color4;
  17246. /**
  17247. * The color change of the particle per step.
  17248. */
  17249. colorStep: Color4;
  17250. /**
  17251. * Defines how long will the life of the particle be.
  17252. */
  17253. lifeTime: number;
  17254. /**
  17255. * The current age of the particle.
  17256. */
  17257. age: number;
  17258. /**
  17259. * The current size of the particle.
  17260. */
  17261. size: number;
  17262. /**
  17263. * The current scale of the particle.
  17264. */
  17265. scale: Vector2;
  17266. /**
  17267. * The current angle of the particle.
  17268. */
  17269. angle: number;
  17270. /**
  17271. * Defines how fast is the angle changing.
  17272. */
  17273. angularSpeed: number;
  17274. /**
  17275. * Defines the cell index used by the particle to be rendered from a sprite.
  17276. */
  17277. cellIndex: number;
  17278. /**
  17279. * The information required to support color remapping
  17280. */
  17281. remapData: Vector4;
  17282. /** @hidden */
  17283. _randomCellOffset?: number;
  17284. /** @hidden */
  17285. _initialDirection: Nullable<Vector3>;
  17286. /** @hidden */
  17287. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17288. /** @hidden */
  17289. _initialStartSpriteCellID: number;
  17290. /** @hidden */
  17291. _initialEndSpriteCellID: number;
  17292. /** @hidden */
  17293. _currentColorGradient: Nullable<ColorGradient>;
  17294. /** @hidden */
  17295. _currentColor1: Color4;
  17296. /** @hidden */
  17297. _currentColor2: Color4;
  17298. /** @hidden */
  17299. _currentSizeGradient: Nullable<FactorGradient>;
  17300. /** @hidden */
  17301. _currentSize1: number;
  17302. /** @hidden */
  17303. _currentSize2: number;
  17304. /** @hidden */
  17305. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17306. /** @hidden */
  17307. _currentAngularSpeed1: number;
  17308. /** @hidden */
  17309. _currentAngularSpeed2: number;
  17310. /** @hidden */
  17311. _currentVelocityGradient: Nullable<FactorGradient>;
  17312. /** @hidden */
  17313. _currentVelocity1: number;
  17314. /** @hidden */
  17315. _currentVelocity2: number;
  17316. /** @hidden */
  17317. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17318. /** @hidden */
  17319. _currentLimitVelocity1: number;
  17320. /** @hidden */
  17321. _currentLimitVelocity2: number;
  17322. /** @hidden */
  17323. _currentDragGradient: Nullable<FactorGradient>;
  17324. /** @hidden */
  17325. _currentDrag1: number;
  17326. /** @hidden */
  17327. _currentDrag2: number;
  17328. /** @hidden */
  17329. _randomNoiseCoordinates1: Vector3;
  17330. /** @hidden */
  17331. _randomNoiseCoordinates2: Vector3;
  17332. /**
  17333. * Creates a new instance Particle
  17334. * @param particleSystem the particle system the particle belongs to
  17335. */
  17336. constructor(
  17337. /**
  17338. * The particle system the particle belongs to.
  17339. */
  17340. particleSystem: ParticleSystem);
  17341. private updateCellInfoFromSystem;
  17342. /**
  17343. * Defines how the sprite cell index is updated for the particle
  17344. */
  17345. updateCellIndex(): void;
  17346. /** @hidden */
  17347. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17348. /** @hidden */
  17349. _inheritParticleInfoToSubEmitters(): void;
  17350. /** @hidden */
  17351. _reset(): void;
  17352. /**
  17353. * Copy the properties of particle to another one.
  17354. * @param other the particle to copy the information to.
  17355. */
  17356. copyTo(other: Particle): void;
  17357. }
  17358. }
  17359. declare module BABYLON {
  17360. /**
  17361. * Particle emitter represents a volume emitting particles.
  17362. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17363. */
  17364. export interface IParticleEmitterType {
  17365. /**
  17366. * Called by the particle System when the direction is computed for the created particle.
  17367. * @param worldMatrix is the world matrix of the particle system
  17368. * @param directionToUpdate is the direction vector to update with the result
  17369. * @param particle is the particle we are computed the direction for
  17370. */
  17371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17372. /**
  17373. * Called by the particle System when the position is computed for the created particle.
  17374. * @param worldMatrix is the world matrix of the particle system
  17375. * @param positionToUpdate is the position vector to update with the result
  17376. * @param particle is the particle we are computed the position for
  17377. */
  17378. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17379. /**
  17380. * Clones the current emitter and returns a copy of it
  17381. * @returns the new emitter
  17382. */
  17383. clone(): IParticleEmitterType;
  17384. /**
  17385. * Called by the GPUParticleSystem to setup the update shader
  17386. * @param effect defines the update shader
  17387. */
  17388. applyToShader(effect: Effect): void;
  17389. /**
  17390. * Returns a string to use to update the GPU particles update shader
  17391. * @returns the effect defines string
  17392. */
  17393. getEffectDefines(): string;
  17394. /**
  17395. * Returns a string representing the class name
  17396. * @returns a string containing the class name
  17397. */
  17398. getClassName(): string;
  17399. /**
  17400. * Serializes the particle system to a JSON object.
  17401. * @returns the JSON object
  17402. */
  17403. serialize(): any;
  17404. /**
  17405. * Parse properties from a JSON object
  17406. * @param serializationObject defines the JSON object
  17407. */
  17408. parse(serializationObject: any): void;
  17409. }
  17410. }
  17411. declare module BABYLON {
  17412. /**
  17413. * Particle emitter emitting particles from the inside of a box.
  17414. * It emits the particles randomly between 2 given directions.
  17415. */
  17416. export class BoxParticleEmitter implements IParticleEmitterType {
  17417. /**
  17418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17419. */
  17420. direction1: Vector3;
  17421. /**
  17422. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17423. */
  17424. direction2: Vector3;
  17425. /**
  17426. * 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.
  17427. */
  17428. minEmitBox: Vector3;
  17429. /**
  17430. * 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.
  17431. */
  17432. maxEmitBox: Vector3;
  17433. /**
  17434. * Creates a new instance BoxParticleEmitter
  17435. */
  17436. constructor();
  17437. /**
  17438. * Called by the particle System when the direction is computed for the created particle.
  17439. * @param worldMatrix is the world matrix of the particle system
  17440. * @param directionToUpdate is the direction vector to update with the result
  17441. * @param particle is the particle we are computed the direction for
  17442. */
  17443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17444. /**
  17445. * Called by the particle System when the position is computed for the created particle.
  17446. * @param worldMatrix is the world matrix of the particle system
  17447. * @param positionToUpdate is the position vector to update with the result
  17448. * @param particle is the particle we are computed the position for
  17449. */
  17450. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17451. /**
  17452. * Clones the current emitter and returns a copy of it
  17453. * @returns the new emitter
  17454. */
  17455. clone(): BoxParticleEmitter;
  17456. /**
  17457. * Called by the GPUParticleSystem to setup the update shader
  17458. * @param effect defines the update shader
  17459. */
  17460. applyToShader(effect: Effect): void;
  17461. /**
  17462. * Returns a string to use to update the GPU particles update shader
  17463. * @returns a string containng the defines string
  17464. */
  17465. getEffectDefines(): string;
  17466. /**
  17467. * Returns the string "BoxParticleEmitter"
  17468. * @returns a string containing the class name
  17469. */
  17470. getClassName(): string;
  17471. /**
  17472. * Serializes the particle system to a JSON object.
  17473. * @returns the JSON object
  17474. */
  17475. serialize(): any;
  17476. /**
  17477. * Parse properties from a JSON object
  17478. * @param serializationObject defines the JSON object
  17479. */
  17480. parse(serializationObject: any): void;
  17481. }
  17482. }
  17483. declare module BABYLON {
  17484. /**
  17485. * Particle emitter emitting particles from the inside of a cone.
  17486. * It emits the particles alongside the cone volume from the base to the particle.
  17487. * The emission direction might be randomized.
  17488. */
  17489. export class ConeParticleEmitter implements IParticleEmitterType {
  17490. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17491. directionRandomizer: number;
  17492. private _radius;
  17493. private _angle;
  17494. private _height;
  17495. /**
  17496. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17497. */
  17498. radiusRange: number;
  17499. /**
  17500. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17501. */
  17502. heightRange: number;
  17503. /**
  17504. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17505. */
  17506. emitFromSpawnPointOnly: boolean;
  17507. /**
  17508. * Gets or sets the radius of the emission cone
  17509. */
  17510. radius: number;
  17511. /**
  17512. * Gets or sets the angle of the emission cone
  17513. */
  17514. angle: number;
  17515. private _buildHeight;
  17516. /**
  17517. * Creates a new instance ConeParticleEmitter
  17518. * @param radius the radius of the emission cone (1 by default)
  17519. * @param angle the cone base angle (PI by default)
  17520. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17521. */
  17522. constructor(radius?: number, angle?: number,
  17523. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17524. directionRandomizer?: number);
  17525. /**
  17526. * Called by the particle System when the direction is computed for the created particle.
  17527. * @param worldMatrix is the world matrix of the particle system
  17528. * @param directionToUpdate is the direction vector to update with the result
  17529. * @param particle is the particle we are computed the direction for
  17530. */
  17531. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17532. /**
  17533. * Called by the particle System when the position is computed for the created particle.
  17534. * @param worldMatrix is the world matrix of the particle system
  17535. * @param positionToUpdate is the position vector to update with the result
  17536. * @param particle is the particle we are computed the position for
  17537. */
  17538. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17539. /**
  17540. * Clones the current emitter and returns a copy of it
  17541. * @returns the new emitter
  17542. */
  17543. clone(): ConeParticleEmitter;
  17544. /**
  17545. * Called by the GPUParticleSystem to setup the update shader
  17546. * @param effect defines the update shader
  17547. */
  17548. applyToShader(effect: Effect): void;
  17549. /**
  17550. * Returns a string to use to update the GPU particles update shader
  17551. * @returns a string containng the defines string
  17552. */
  17553. getEffectDefines(): string;
  17554. /**
  17555. * Returns the string "ConeParticleEmitter"
  17556. * @returns a string containing the class name
  17557. */
  17558. getClassName(): string;
  17559. /**
  17560. * Serializes the particle system to a JSON object.
  17561. * @returns the JSON object
  17562. */
  17563. serialize(): any;
  17564. /**
  17565. * Parse properties from a JSON object
  17566. * @param serializationObject defines the JSON object
  17567. */
  17568. parse(serializationObject: any): void;
  17569. }
  17570. }
  17571. declare module BABYLON {
  17572. /**
  17573. * Particle emitter emitting particles from the inside of a cylinder.
  17574. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17575. */
  17576. export class CylinderParticleEmitter implements IParticleEmitterType {
  17577. /**
  17578. * The radius of the emission cylinder.
  17579. */
  17580. radius: number;
  17581. /**
  17582. * The height of the emission cylinder.
  17583. */
  17584. height: number;
  17585. /**
  17586. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17587. */
  17588. radiusRange: number;
  17589. /**
  17590. * How much to randomize the particle direction [0-1].
  17591. */
  17592. directionRandomizer: number;
  17593. /**
  17594. * Creates a new instance CylinderParticleEmitter
  17595. * @param radius the radius of the emission cylinder (1 by default)
  17596. * @param height the height of the emission cylinder (1 by default)
  17597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17598. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17599. */
  17600. constructor(
  17601. /**
  17602. * The radius of the emission cylinder.
  17603. */
  17604. radius?: number,
  17605. /**
  17606. * The height of the emission cylinder.
  17607. */
  17608. height?: number,
  17609. /**
  17610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17611. */
  17612. radiusRange?: number,
  17613. /**
  17614. * How much to randomize the particle direction [0-1].
  17615. */
  17616. directionRandomizer?: number);
  17617. /**
  17618. * Called by the particle System when the direction is computed for the created particle.
  17619. * @param worldMatrix is the world matrix of the particle system
  17620. * @param directionToUpdate is the direction vector to update with the result
  17621. * @param particle is the particle we are computed the direction for
  17622. */
  17623. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17624. /**
  17625. * Called by the particle System when the position is computed for the created particle.
  17626. * @param worldMatrix is the world matrix of the particle system
  17627. * @param positionToUpdate is the position vector to update with the result
  17628. * @param particle is the particle we are computed the position for
  17629. */
  17630. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17631. /**
  17632. * Clones the current emitter and returns a copy of it
  17633. * @returns the new emitter
  17634. */
  17635. clone(): CylinderParticleEmitter;
  17636. /**
  17637. * Called by the GPUParticleSystem to setup the update shader
  17638. * @param effect defines the update shader
  17639. */
  17640. applyToShader(effect: Effect): void;
  17641. /**
  17642. * Returns a string to use to update the GPU particles update shader
  17643. * @returns a string containng the defines string
  17644. */
  17645. getEffectDefines(): string;
  17646. /**
  17647. * Returns the string "CylinderParticleEmitter"
  17648. * @returns a string containing the class name
  17649. */
  17650. getClassName(): string;
  17651. /**
  17652. * Serializes the particle system to a JSON object.
  17653. * @returns the JSON object
  17654. */
  17655. serialize(): any;
  17656. /**
  17657. * Parse properties from a JSON object
  17658. * @param serializationObject defines the JSON object
  17659. */
  17660. parse(serializationObject: any): void;
  17661. }
  17662. /**
  17663. * Particle emitter emitting particles from the inside of a cylinder.
  17664. * It emits the particles randomly between two vectors.
  17665. */
  17666. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17667. /**
  17668. * The min limit of the emission direction.
  17669. */
  17670. direction1: Vector3;
  17671. /**
  17672. * The max limit of the emission direction.
  17673. */
  17674. direction2: Vector3;
  17675. /**
  17676. * Creates a new instance CylinderDirectedParticleEmitter
  17677. * @param radius the radius of the emission cylinder (1 by default)
  17678. * @param height the height of the emission cylinder (1 by default)
  17679. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17680. * @param direction1 the min limit of the emission direction (up vector by default)
  17681. * @param direction2 the max limit of the emission direction (up vector by default)
  17682. */
  17683. constructor(radius?: number, height?: number, radiusRange?: number,
  17684. /**
  17685. * The min limit of the emission direction.
  17686. */
  17687. direction1?: Vector3,
  17688. /**
  17689. * The max limit of the emission direction.
  17690. */
  17691. direction2?: Vector3);
  17692. /**
  17693. * Called by the particle System when the direction is computed for the created particle.
  17694. * @param worldMatrix is the world matrix of the particle system
  17695. * @param directionToUpdate is the direction vector to update with the result
  17696. * @param particle is the particle we are computed the direction for
  17697. */
  17698. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17699. /**
  17700. * Clones the current emitter and returns a copy of it
  17701. * @returns the new emitter
  17702. */
  17703. clone(): CylinderDirectedParticleEmitter;
  17704. /**
  17705. * Called by the GPUParticleSystem to setup the update shader
  17706. * @param effect defines the update shader
  17707. */
  17708. applyToShader(effect: Effect): void;
  17709. /**
  17710. * Returns a string to use to update the GPU particles update shader
  17711. * @returns a string containng the defines string
  17712. */
  17713. getEffectDefines(): string;
  17714. /**
  17715. * Returns the string "CylinderDirectedParticleEmitter"
  17716. * @returns a string containing the class name
  17717. */
  17718. getClassName(): string;
  17719. /**
  17720. * Serializes the particle system to a JSON object.
  17721. * @returns the JSON object
  17722. */
  17723. serialize(): any;
  17724. /**
  17725. * Parse properties from a JSON object
  17726. * @param serializationObject defines the JSON object
  17727. */
  17728. parse(serializationObject: any): void;
  17729. }
  17730. }
  17731. declare module BABYLON {
  17732. /**
  17733. * Particle emitter emitting particles from the inside of a hemisphere.
  17734. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17735. */
  17736. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17737. /**
  17738. * The radius of the emission hemisphere.
  17739. */
  17740. radius: number;
  17741. /**
  17742. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17743. */
  17744. radiusRange: number;
  17745. /**
  17746. * How much to randomize the particle direction [0-1].
  17747. */
  17748. directionRandomizer: number;
  17749. /**
  17750. * Creates a new instance HemisphericParticleEmitter
  17751. * @param radius the radius of the emission hemisphere (1 by default)
  17752. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17753. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17754. */
  17755. constructor(
  17756. /**
  17757. * The radius of the emission hemisphere.
  17758. */
  17759. radius?: number,
  17760. /**
  17761. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17762. */
  17763. radiusRange?: number,
  17764. /**
  17765. * How much to randomize the particle direction [0-1].
  17766. */
  17767. directionRandomizer?: number);
  17768. /**
  17769. * Called by the particle System when the direction is computed for the created particle.
  17770. * @param worldMatrix is the world matrix of the particle system
  17771. * @param directionToUpdate is the direction vector to update with the result
  17772. * @param particle is the particle we are computed the direction for
  17773. */
  17774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17775. /**
  17776. * Called by the particle System when the position is computed for the created particle.
  17777. * @param worldMatrix is the world matrix of the particle system
  17778. * @param positionToUpdate is the position vector to update with the result
  17779. * @param particle is the particle we are computed the position for
  17780. */
  17781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17782. /**
  17783. * Clones the current emitter and returns a copy of it
  17784. * @returns the new emitter
  17785. */
  17786. clone(): HemisphericParticleEmitter;
  17787. /**
  17788. * Called by the GPUParticleSystem to setup the update shader
  17789. * @param effect defines the update shader
  17790. */
  17791. applyToShader(effect: Effect): void;
  17792. /**
  17793. * Returns a string to use to update the GPU particles update shader
  17794. * @returns a string containng the defines string
  17795. */
  17796. getEffectDefines(): string;
  17797. /**
  17798. * Returns the string "HemisphericParticleEmitter"
  17799. * @returns a string containing the class name
  17800. */
  17801. getClassName(): string;
  17802. /**
  17803. * Serializes the particle system to a JSON object.
  17804. * @returns the JSON object
  17805. */
  17806. serialize(): any;
  17807. /**
  17808. * Parse properties from a JSON object
  17809. * @param serializationObject defines the JSON object
  17810. */
  17811. parse(serializationObject: any): void;
  17812. }
  17813. }
  17814. declare module BABYLON {
  17815. /**
  17816. * Particle emitter emitting particles from a point.
  17817. * It emits the particles randomly between 2 given directions.
  17818. */
  17819. export class PointParticleEmitter implements IParticleEmitterType {
  17820. /**
  17821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17822. */
  17823. direction1: Vector3;
  17824. /**
  17825. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17826. */
  17827. direction2: Vector3;
  17828. /**
  17829. * Creates a new instance PointParticleEmitter
  17830. */
  17831. constructor();
  17832. /**
  17833. * Called by the particle System when the direction is computed for the created particle.
  17834. * @param worldMatrix is the world matrix of the particle system
  17835. * @param directionToUpdate is the direction vector to update with the result
  17836. * @param particle is the particle we are computed the direction for
  17837. */
  17838. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17839. /**
  17840. * Called by the particle System when the position is computed for the created particle.
  17841. * @param worldMatrix is the world matrix of the particle system
  17842. * @param positionToUpdate is the position vector to update with the result
  17843. * @param particle is the particle we are computed the position for
  17844. */
  17845. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17846. /**
  17847. * Clones the current emitter and returns a copy of it
  17848. * @returns the new emitter
  17849. */
  17850. clone(): PointParticleEmitter;
  17851. /**
  17852. * Called by the GPUParticleSystem to setup the update shader
  17853. * @param effect defines the update shader
  17854. */
  17855. applyToShader(effect: Effect): void;
  17856. /**
  17857. * Returns a string to use to update the GPU particles update shader
  17858. * @returns a string containng the defines string
  17859. */
  17860. getEffectDefines(): string;
  17861. /**
  17862. * Returns the string "PointParticleEmitter"
  17863. * @returns a string containing the class name
  17864. */
  17865. getClassName(): string;
  17866. /**
  17867. * Serializes the particle system to a JSON object.
  17868. * @returns the JSON object
  17869. */
  17870. serialize(): any;
  17871. /**
  17872. * Parse properties from a JSON object
  17873. * @param serializationObject defines the JSON object
  17874. */
  17875. parse(serializationObject: any): void;
  17876. }
  17877. }
  17878. declare module BABYLON {
  17879. /**
  17880. * Particle emitter emitting particles from the inside of a sphere.
  17881. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17882. */
  17883. export class SphereParticleEmitter implements IParticleEmitterType {
  17884. /**
  17885. * The radius of the emission sphere.
  17886. */
  17887. radius: number;
  17888. /**
  17889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17890. */
  17891. radiusRange: number;
  17892. /**
  17893. * How much to randomize the particle direction [0-1].
  17894. */
  17895. directionRandomizer: number;
  17896. /**
  17897. * Creates a new instance SphereParticleEmitter
  17898. * @param radius the radius of the emission sphere (1 by default)
  17899. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17900. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17901. */
  17902. constructor(
  17903. /**
  17904. * The radius of the emission sphere.
  17905. */
  17906. radius?: number,
  17907. /**
  17908. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17909. */
  17910. radiusRange?: number,
  17911. /**
  17912. * How much to randomize the particle direction [0-1].
  17913. */
  17914. directionRandomizer?: number);
  17915. /**
  17916. * Called by the particle System when the direction is computed for the created particle.
  17917. * @param worldMatrix is the world matrix of the particle system
  17918. * @param directionToUpdate is the direction vector to update with the result
  17919. * @param particle is the particle we are computed the direction for
  17920. */
  17921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17922. /**
  17923. * Called by the particle System when the position is computed for the created particle.
  17924. * @param worldMatrix is the world matrix of the particle system
  17925. * @param positionToUpdate is the position vector to update with the result
  17926. * @param particle is the particle we are computed the position for
  17927. */
  17928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17929. /**
  17930. * Clones the current emitter and returns a copy of it
  17931. * @returns the new emitter
  17932. */
  17933. clone(): SphereParticleEmitter;
  17934. /**
  17935. * Called by the GPUParticleSystem to setup the update shader
  17936. * @param effect defines the update shader
  17937. */
  17938. applyToShader(effect: Effect): void;
  17939. /**
  17940. * Returns a string to use to update the GPU particles update shader
  17941. * @returns a string containng the defines string
  17942. */
  17943. getEffectDefines(): string;
  17944. /**
  17945. * Returns the string "SphereParticleEmitter"
  17946. * @returns a string containing the class name
  17947. */
  17948. getClassName(): string;
  17949. /**
  17950. * Serializes the particle system to a JSON object.
  17951. * @returns the JSON object
  17952. */
  17953. serialize(): any;
  17954. /**
  17955. * Parse properties from a JSON object
  17956. * @param serializationObject defines the JSON object
  17957. */
  17958. parse(serializationObject: any): void;
  17959. }
  17960. /**
  17961. * Particle emitter emitting particles from the inside of a sphere.
  17962. * It emits the particles randomly between two vectors.
  17963. */
  17964. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17965. /**
  17966. * The min limit of the emission direction.
  17967. */
  17968. direction1: Vector3;
  17969. /**
  17970. * The max limit of the emission direction.
  17971. */
  17972. direction2: Vector3;
  17973. /**
  17974. * Creates a new instance SphereDirectedParticleEmitter
  17975. * @param radius the radius of the emission sphere (1 by default)
  17976. * @param direction1 the min limit of the emission direction (up vector by default)
  17977. * @param direction2 the max limit of the emission direction (up vector by default)
  17978. */
  17979. constructor(radius?: number,
  17980. /**
  17981. * The min limit of the emission direction.
  17982. */
  17983. direction1?: Vector3,
  17984. /**
  17985. * The max limit of the emission direction.
  17986. */
  17987. direction2?: Vector3);
  17988. /**
  17989. * Called by the particle System when the direction is computed for the created particle.
  17990. * @param worldMatrix is the world matrix of the particle system
  17991. * @param directionToUpdate is the direction vector to update with the result
  17992. * @param particle is the particle we are computed the direction for
  17993. */
  17994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17995. /**
  17996. * Clones the current emitter and returns a copy of it
  17997. * @returns the new emitter
  17998. */
  17999. clone(): SphereDirectedParticleEmitter;
  18000. /**
  18001. * Called by the GPUParticleSystem to setup the update shader
  18002. * @param effect defines the update shader
  18003. */
  18004. applyToShader(effect: Effect): void;
  18005. /**
  18006. * Returns a string to use to update the GPU particles update shader
  18007. * @returns a string containng the defines string
  18008. */
  18009. getEffectDefines(): string;
  18010. /**
  18011. * Returns the string "SphereDirectedParticleEmitter"
  18012. * @returns a string containing the class name
  18013. */
  18014. getClassName(): string;
  18015. /**
  18016. * Serializes the particle system to a JSON object.
  18017. * @returns the JSON object
  18018. */
  18019. serialize(): any;
  18020. /**
  18021. * Parse properties from a JSON object
  18022. * @param serializationObject defines the JSON object
  18023. */
  18024. parse(serializationObject: any): void;
  18025. }
  18026. }
  18027. declare module BABYLON {
  18028. /**
  18029. * Interface representing a particle system in Babylon.js.
  18030. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18031. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18032. */
  18033. export interface IParticleSystem {
  18034. /**
  18035. * List of animations used by the particle system.
  18036. */
  18037. animations: Animation[];
  18038. /**
  18039. * The id of the Particle system.
  18040. */
  18041. id: string;
  18042. /**
  18043. * The name of the Particle system.
  18044. */
  18045. name: string;
  18046. /**
  18047. * The emitter represents the Mesh or position we are attaching the particle system to.
  18048. */
  18049. emitter: Nullable<AbstractMesh | Vector3>;
  18050. /**
  18051. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18052. */
  18053. isBillboardBased: boolean;
  18054. /**
  18055. * The rendering group used by the Particle system to chose when to render.
  18056. */
  18057. renderingGroupId: number;
  18058. /**
  18059. * The layer mask we are rendering the particles through.
  18060. */
  18061. layerMask: number;
  18062. /**
  18063. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18064. */
  18065. updateSpeed: number;
  18066. /**
  18067. * The amount of time the particle system is running (depends of the overall update speed).
  18068. */
  18069. targetStopDuration: number;
  18070. /**
  18071. * The texture used to render each particle. (this can be a spritesheet)
  18072. */
  18073. particleTexture: Nullable<Texture>;
  18074. /**
  18075. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18076. */
  18077. blendMode: number;
  18078. /**
  18079. * Minimum life time of emitting particles.
  18080. */
  18081. minLifeTime: number;
  18082. /**
  18083. * Maximum life time of emitting particles.
  18084. */
  18085. maxLifeTime: number;
  18086. /**
  18087. * Minimum Size of emitting particles.
  18088. */
  18089. minSize: number;
  18090. /**
  18091. * Maximum Size of emitting particles.
  18092. */
  18093. maxSize: number;
  18094. /**
  18095. * Minimum scale of emitting particles on X axis.
  18096. */
  18097. minScaleX: number;
  18098. /**
  18099. * Maximum scale of emitting particles on X axis.
  18100. */
  18101. maxScaleX: number;
  18102. /**
  18103. * Minimum scale of emitting particles on Y axis.
  18104. */
  18105. minScaleY: number;
  18106. /**
  18107. * Maximum scale of emitting particles on Y axis.
  18108. */
  18109. maxScaleY: number;
  18110. /**
  18111. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18112. */
  18113. color1: Color4;
  18114. /**
  18115. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18116. */
  18117. color2: Color4;
  18118. /**
  18119. * Color the particle will have at the end of its lifetime.
  18120. */
  18121. colorDead: Color4;
  18122. /**
  18123. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18124. */
  18125. emitRate: number;
  18126. /**
  18127. * You can use gravity if you want to give an orientation to your particles.
  18128. */
  18129. gravity: Vector3;
  18130. /**
  18131. * Minimum power of emitting particles.
  18132. */
  18133. minEmitPower: number;
  18134. /**
  18135. * Maximum power of emitting particles.
  18136. */
  18137. maxEmitPower: number;
  18138. /**
  18139. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18140. */
  18141. minAngularSpeed: number;
  18142. /**
  18143. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18144. */
  18145. maxAngularSpeed: number;
  18146. /**
  18147. * Gets or sets the minimal initial rotation in radians.
  18148. */
  18149. minInitialRotation: number;
  18150. /**
  18151. * Gets or sets the maximal initial rotation in radians.
  18152. */
  18153. maxInitialRotation: number;
  18154. /**
  18155. * The particle emitter type defines the emitter used by the particle system.
  18156. * It can be for example box, sphere, or cone...
  18157. */
  18158. particleEmitterType: Nullable<IParticleEmitterType>;
  18159. /**
  18160. * Defines the delay in milliseconds before starting the system (0 by default)
  18161. */
  18162. startDelay: number;
  18163. /**
  18164. * 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
  18165. */
  18166. preWarmCycles: number;
  18167. /**
  18168. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18169. */
  18170. preWarmStepOffset: number;
  18171. /**
  18172. * 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)
  18173. */
  18174. spriteCellChangeSpeed: number;
  18175. /**
  18176. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18177. */
  18178. startSpriteCellID: number;
  18179. /**
  18180. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18181. */
  18182. endSpriteCellID: number;
  18183. /**
  18184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18185. */
  18186. spriteCellWidth: number;
  18187. /**
  18188. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18189. */
  18190. spriteCellHeight: number;
  18191. /**
  18192. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18193. */
  18194. spriteRandomStartCell: boolean;
  18195. /**
  18196. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18197. */
  18198. isAnimationSheetEnabled: boolean;
  18199. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18200. translationPivot: Vector2;
  18201. /**
  18202. * Gets or sets a texture used to add random noise to particle positions
  18203. */
  18204. noiseTexture: Nullable<BaseTexture>;
  18205. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18206. noiseStrength: Vector3;
  18207. /**
  18208. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18209. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18210. */
  18211. billboardMode: number;
  18212. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18213. limitVelocityDamping: number;
  18214. /**
  18215. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18216. */
  18217. beginAnimationOnStart: boolean;
  18218. /**
  18219. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18220. */
  18221. beginAnimationFrom: number;
  18222. /**
  18223. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18224. */
  18225. beginAnimationTo: number;
  18226. /**
  18227. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18228. */
  18229. beginAnimationLoop: boolean;
  18230. /**
  18231. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18232. */
  18233. disposeOnStop: boolean;
  18234. /**
  18235. * Gets the maximum number of particles active at the same time.
  18236. * @returns The max number of active particles.
  18237. */
  18238. getCapacity(): number;
  18239. /**
  18240. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18241. * @returns True if it has been started, otherwise false.
  18242. */
  18243. isStarted(): boolean;
  18244. /**
  18245. * Animates the particle system for this frame.
  18246. */
  18247. animate(): void;
  18248. /**
  18249. * Renders the particle system in its current state.
  18250. * @returns the current number of particles
  18251. */
  18252. render(): number;
  18253. /**
  18254. * Dispose the particle system and frees its associated resources.
  18255. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18256. */
  18257. dispose(disposeTexture?: boolean): void;
  18258. /**
  18259. * Clones the particle system.
  18260. * @param name The name of the cloned object
  18261. * @param newEmitter The new emitter to use
  18262. * @returns the cloned particle system
  18263. */
  18264. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18265. /**
  18266. * Serializes the particle system to a JSON object.
  18267. * @returns the JSON object
  18268. */
  18269. serialize(): any;
  18270. /**
  18271. * Rebuild the particle system
  18272. */
  18273. rebuild(): void;
  18274. /**
  18275. * Starts the particle system and begins to emit
  18276. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18277. */
  18278. start(delay?: number): void;
  18279. /**
  18280. * Stops the particle system.
  18281. */
  18282. stop(): void;
  18283. /**
  18284. * Remove all active particles
  18285. */
  18286. reset(): void;
  18287. /**
  18288. * Is this system ready to be used/rendered
  18289. * @return true if the system is ready
  18290. */
  18291. isReady(): boolean;
  18292. /**
  18293. * Adds a new color gradient
  18294. * @param gradient defines the gradient to use (between 0 and 1)
  18295. * @param color1 defines the color to affect to the specified gradient
  18296. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18297. * @returns the current particle system
  18298. */
  18299. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18300. /**
  18301. * Remove a specific color gradient
  18302. * @param gradient defines the gradient to remove
  18303. * @returns the current particle system
  18304. */
  18305. removeColorGradient(gradient: number): IParticleSystem;
  18306. /**
  18307. * Adds a new size gradient
  18308. * @param gradient defines the gradient to use (between 0 and 1)
  18309. * @param factor defines the size factor to affect to the specified gradient
  18310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18311. * @returns the current particle system
  18312. */
  18313. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18314. /**
  18315. * Remove a specific size gradient
  18316. * @param gradient defines the gradient to remove
  18317. * @returns the current particle system
  18318. */
  18319. removeSizeGradient(gradient: number): IParticleSystem;
  18320. /**
  18321. * Gets the current list of color gradients.
  18322. * You must use addColorGradient and removeColorGradient to udpate this list
  18323. * @returns the list of color gradients
  18324. */
  18325. getColorGradients(): Nullable<Array<ColorGradient>>;
  18326. /**
  18327. * Gets the current list of size gradients.
  18328. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18329. * @returns the list of size gradients
  18330. */
  18331. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18332. /**
  18333. * Gets the current list of angular speed gradients.
  18334. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18335. * @returns the list of angular speed gradients
  18336. */
  18337. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18338. /**
  18339. * Adds a new angular speed gradient
  18340. * @param gradient defines the gradient to use (between 0 and 1)
  18341. * @param factor defines the angular speed to affect to the specified gradient
  18342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18343. * @returns the current particle system
  18344. */
  18345. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18346. /**
  18347. * Remove a specific angular speed gradient
  18348. * @param gradient defines the gradient to remove
  18349. * @returns the current particle system
  18350. */
  18351. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18352. /**
  18353. * Gets the current list of velocity gradients.
  18354. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18355. * @returns the list of velocity gradients
  18356. */
  18357. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18358. /**
  18359. * Adds a new velocity gradient
  18360. * @param gradient defines the gradient to use (between 0 and 1)
  18361. * @param factor defines the velocity to affect to the specified gradient
  18362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18363. * @returns the current particle system
  18364. */
  18365. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18366. /**
  18367. * Remove a specific velocity gradient
  18368. * @param gradient defines the gradient to remove
  18369. * @returns the current particle system
  18370. */
  18371. removeVelocityGradient(gradient: number): IParticleSystem;
  18372. /**
  18373. * Gets the current list of limit velocity gradients.
  18374. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18375. * @returns the list of limit velocity gradients
  18376. */
  18377. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18378. /**
  18379. * Adds a new limit velocity gradient
  18380. * @param gradient defines the gradient to use (between 0 and 1)
  18381. * @param factor defines the limit velocity to affect to the specified gradient
  18382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18383. * @returns the current particle system
  18384. */
  18385. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18386. /**
  18387. * Remove a specific limit velocity gradient
  18388. * @param gradient defines the gradient to remove
  18389. * @returns the current particle system
  18390. */
  18391. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18392. /**
  18393. * Adds a new drag gradient
  18394. * @param gradient defines the gradient to use (between 0 and 1)
  18395. * @param factor defines the drag to affect to the specified gradient
  18396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18397. * @returns the current particle system
  18398. */
  18399. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18400. /**
  18401. * Remove a specific drag gradient
  18402. * @param gradient defines the gradient to remove
  18403. * @returns the current particle system
  18404. */
  18405. removeDragGradient(gradient: number): IParticleSystem;
  18406. /**
  18407. * Gets the current list of drag gradients.
  18408. * You must use addDragGradient and removeDragGradient to udpate this list
  18409. * @returns the list of drag gradients
  18410. */
  18411. getDragGradients(): Nullable<Array<FactorGradient>>;
  18412. /**
  18413. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18414. * @param gradient defines the gradient to use (between 0 and 1)
  18415. * @param factor defines the emit rate to affect to the specified gradient
  18416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18417. * @returns the current particle system
  18418. */
  18419. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18420. /**
  18421. * Remove a specific emit rate gradient
  18422. * @param gradient defines the gradient to remove
  18423. * @returns the current particle system
  18424. */
  18425. removeEmitRateGradient(gradient: number): IParticleSystem;
  18426. /**
  18427. * Gets the current list of emit rate gradients.
  18428. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18429. * @returns the list of emit rate gradients
  18430. */
  18431. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18432. /**
  18433. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18434. * @param gradient defines the gradient to use (between 0 and 1)
  18435. * @param factor defines the start size to affect to the specified gradient
  18436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18437. * @returns the current particle system
  18438. */
  18439. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18440. /**
  18441. * Remove a specific start size gradient
  18442. * @param gradient defines the gradient to remove
  18443. * @returns the current particle system
  18444. */
  18445. removeStartSizeGradient(gradient: number): IParticleSystem;
  18446. /**
  18447. * Gets the current list of start size gradients.
  18448. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18449. * @returns the list of start size gradients
  18450. */
  18451. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18452. /**
  18453. * Adds a new life time gradient
  18454. * @param gradient defines the gradient to use (between 0 and 1)
  18455. * @param factor defines the life time factor to affect to the specified gradient
  18456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18457. * @returns the current particle system
  18458. */
  18459. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18460. /**
  18461. * Remove a specific life time gradient
  18462. * @param gradient defines the gradient to remove
  18463. * @returns the current particle system
  18464. */
  18465. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18466. /**
  18467. * Gets the current list of life time gradients.
  18468. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18469. * @returns the list of life time gradients
  18470. */
  18471. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18472. /**
  18473. * Gets the current list of color gradients.
  18474. * You must use addColorGradient and removeColorGradient to udpate this list
  18475. * @returns the list of color gradients
  18476. */
  18477. getColorGradients(): Nullable<Array<ColorGradient>>;
  18478. /**
  18479. * Adds a new ramp gradient used to remap particle colors
  18480. * @param gradient defines the gradient to use (between 0 and 1)
  18481. * @param color defines the color to affect to the specified gradient
  18482. * @returns the current particle system
  18483. */
  18484. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18485. /**
  18486. * Gets the current list of ramp gradients.
  18487. * You must use addRampGradient and removeRampGradient to udpate this list
  18488. * @returns the list of ramp gradients
  18489. */
  18490. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18491. /** Gets or sets a boolean indicating that ramp gradients must be used
  18492. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18493. */
  18494. useRampGradients: boolean;
  18495. /**
  18496. * Adds a new color remap gradient
  18497. * @param gradient defines the gradient to use (between 0 and 1)
  18498. * @param min defines the color remap minimal range
  18499. * @param max defines the color remap maximal range
  18500. * @returns the current particle system
  18501. */
  18502. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18503. /**
  18504. * Gets the current list of color remap gradients.
  18505. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18506. * @returns the list of color remap gradients
  18507. */
  18508. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18509. /**
  18510. * Adds a new alpha remap gradient
  18511. * @param gradient defines the gradient to use (between 0 and 1)
  18512. * @param min defines the alpha remap minimal range
  18513. * @param max defines the alpha remap maximal range
  18514. * @returns the current particle system
  18515. */
  18516. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18517. /**
  18518. * Gets the current list of alpha remap gradients.
  18519. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18520. * @returns the list of alpha remap gradients
  18521. */
  18522. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18523. /**
  18524. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18525. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18526. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18527. * @returns the emitter
  18528. */
  18529. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18530. /**
  18531. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18532. * @param radius The radius of the hemisphere to emit from
  18533. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18534. * @returns the emitter
  18535. */
  18536. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18537. /**
  18538. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18539. * @param radius The radius of the sphere to emit from
  18540. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18541. * @returns the emitter
  18542. */
  18543. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18544. /**
  18545. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18546. * @param radius The radius of the sphere to emit from
  18547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18549. * @returns the emitter
  18550. */
  18551. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18552. /**
  18553. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18554. * @param radius The radius of the emission cylinder
  18555. * @param height The height of the emission cylinder
  18556. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18557. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18558. * @returns the emitter
  18559. */
  18560. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18561. /**
  18562. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18563. * @param radius The radius of the cylinder to emit from
  18564. * @param height The height of the emission cylinder
  18565. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18566. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18567. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18568. * @returns the emitter
  18569. */
  18570. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18571. /**
  18572. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18573. * @param radius The radius of the cone to emit from
  18574. * @param angle The base angle of the cone
  18575. * @returns the emitter
  18576. */
  18577. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18578. /**
  18579. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18580. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18581. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18582. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18583. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18584. * @returns the emitter
  18585. */
  18586. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18587. /**
  18588. * Get hosting scene
  18589. * @returns the scene
  18590. */
  18591. getScene(): Scene;
  18592. }
  18593. }
  18594. declare module BABYLON {
  18595. /**
  18596. * Creates an instance based on a source mesh.
  18597. */
  18598. export class InstancedMesh extends AbstractMesh {
  18599. private _sourceMesh;
  18600. private _currentLOD;
  18601. /** @hidden */
  18602. _indexInSourceMeshInstanceArray: number;
  18603. constructor(name: string, source: Mesh);
  18604. /**
  18605. * Returns the string "InstancedMesh".
  18606. */
  18607. getClassName(): string;
  18608. /** Gets the list of lights affecting that mesh */
  18609. readonly lightSources: Light[];
  18610. _resyncLightSources(): void;
  18611. _resyncLighSource(light: Light): void;
  18612. _removeLightSource(light: Light, dispose: boolean): void;
  18613. /**
  18614. * If the source mesh receives shadows
  18615. */
  18616. readonly receiveShadows: boolean;
  18617. /**
  18618. * The material of the source mesh
  18619. */
  18620. readonly material: Nullable<Material>;
  18621. /**
  18622. * Visibility of the source mesh
  18623. */
  18624. readonly visibility: number;
  18625. /**
  18626. * Skeleton of the source mesh
  18627. */
  18628. readonly skeleton: Nullable<Skeleton>;
  18629. /**
  18630. * Rendering ground id of the source mesh
  18631. */
  18632. renderingGroupId: number;
  18633. /**
  18634. * Returns the total number of vertices (integer).
  18635. */
  18636. getTotalVertices(): number;
  18637. /**
  18638. * Returns a positive integer : the total number of indices in this mesh geometry.
  18639. * @returns the numner of indices or zero if the mesh has no geometry.
  18640. */
  18641. getTotalIndices(): number;
  18642. /**
  18643. * The source mesh of the instance
  18644. */
  18645. readonly sourceMesh: Mesh;
  18646. /**
  18647. * Is this node ready to be used/rendered
  18648. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18649. * @return {boolean} is it ready
  18650. */
  18651. isReady(completeCheck?: boolean): boolean;
  18652. /**
  18653. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18654. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18655. * @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.
  18656. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18657. */
  18658. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18659. /**
  18660. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18661. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18662. * The `data` are either a numeric array either a Float32Array.
  18663. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18664. * 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).
  18665. * Note that a new underlying VertexBuffer object is created each call.
  18666. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18667. *
  18668. * Possible `kind` values :
  18669. * - VertexBuffer.PositionKind
  18670. * - VertexBuffer.UVKind
  18671. * - VertexBuffer.UV2Kind
  18672. * - VertexBuffer.UV3Kind
  18673. * - VertexBuffer.UV4Kind
  18674. * - VertexBuffer.UV5Kind
  18675. * - VertexBuffer.UV6Kind
  18676. * - VertexBuffer.ColorKind
  18677. * - VertexBuffer.MatricesIndicesKind
  18678. * - VertexBuffer.MatricesIndicesExtraKind
  18679. * - VertexBuffer.MatricesWeightsKind
  18680. * - VertexBuffer.MatricesWeightsExtraKind
  18681. *
  18682. * Returns the Mesh.
  18683. */
  18684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18685. /**
  18686. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18687. * If the mesh has no geometry, it is simply returned as it is.
  18688. * The `data` are either a numeric array either a Float32Array.
  18689. * No new underlying VertexBuffer object is created.
  18690. * 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.
  18691. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18692. *
  18693. * Possible `kind` values :
  18694. * - VertexBuffer.PositionKind
  18695. * - VertexBuffer.UVKind
  18696. * - VertexBuffer.UV2Kind
  18697. * - VertexBuffer.UV3Kind
  18698. * - VertexBuffer.UV4Kind
  18699. * - VertexBuffer.UV5Kind
  18700. * - VertexBuffer.UV6Kind
  18701. * - VertexBuffer.ColorKind
  18702. * - VertexBuffer.MatricesIndicesKind
  18703. * - VertexBuffer.MatricesIndicesExtraKind
  18704. * - VertexBuffer.MatricesWeightsKind
  18705. * - VertexBuffer.MatricesWeightsExtraKind
  18706. *
  18707. * Returns the Mesh.
  18708. */
  18709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18710. /**
  18711. * Sets the mesh indices.
  18712. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18713. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18714. * This method creates a new index buffer each call.
  18715. * Returns the Mesh.
  18716. */
  18717. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18718. /**
  18719. * Boolean : True if the mesh owns the requested kind of data.
  18720. */
  18721. isVerticesDataPresent(kind: string): boolean;
  18722. /**
  18723. * Returns an array of indices (IndicesArray).
  18724. */
  18725. getIndices(): Nullable<IndicesArray>;
  18726. readonly _positions: Nullable<Vector3[]>;
  18727. /**
  18728. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18729. * This means the mesh underlying bounding box and sphere are recomputed.
  18730. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18731. * @returns the current mesh
  18732. */
  18733. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18734. /** @hidden */
  18735. _preActivate(): InstancedMesh;
  18736. /** @hidden */
  18737. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18738. /** @hidden */
  18739. _postActivate(): void;
  18740. getWorldMatrix(): Matrix;
  18741. readonly isAnInstance: boolean;
  18742. /**
  18743. * Returns the current associated LOD AbstractMesh.
  18744. */
  18745. getLOD(camera: Camera): AbstractMesh;
  18746. /** @hidden */
  18747. _syncSubMeshes(): InstancedMesh;
  18748. /** @hidden */
  18749. _generatePointsArray(): boolean;
  18750. /**
  18751. * Creates a new InstancedMesh from the current mesh.
  18752. * - name (string) : the cloned mesh name
  18753. * - newParent (optional Node) : the optional Node to parent the clone to.
  18754. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18755. *
  18756. * Returns the clone.
  18757. */
  18758. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18759. /**
  18760. * Disposes the InstancedMesh.
  18761. * Returns nothing.
  18762. */
  18763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18764. }
  18765. }
  18766. declare module BABYLON {
  18767. /**
  18768. * Defines the options associated with the creation of a shader material.
  18769. */
  18770. export interface IShaderMaterialOptions {
  18771. /**
  18772. * Does the material work in alpha blend mode
  18773. */
  18774. needAlphaBlending: boolean;
  18775. /**
  18776. * Does the material work in alpha test mode
  18777. */
  18778. needAlphaTesting: boolean;
  18779. /**
  18780. * The list of attribute names used in the shader
  18781. */
  18782. attributes: string[];
  18783. /**
  18784. * The list of unifrom names used in the shader
  18785. */
  18786. uniforms: string[];
  18787. /**
  18788. * The list of UBO names used in the shader
  18789. */
  18790. uniformBuffers: string[];
  18791. /**
  18792. * The list of sampler names used in the shader
  18793. */
  18794. samplers: string[];
  18795. /**
  18796. * The list of defines used in the shader
  18797. */
  18798. defines: string[];
  18799. }
  18800. /**
  18801. * 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.
  18802. *
  18803. * This returned material effects how the mesh will look based on the code in the shaders.
  18804. *
  18805. * @see http://doc.babylonjs.com/how_to/shader_material
  18806. */
  18807. export class ShaderMaterial extends Material {
  18808. private _shaderPath;
  18809. private _options;
  18810. private _textures;
  18811. private _textureArrays;
  18812. private _floats;
  18813. private _ints;
  18814. private _floatsArrays;
  18815. private _colors3;
  18816. private _colors3Arrays;
  18817. private _colors4;
  18818. private _colors4Arrays;
  18819. private _vectors2;
  18820. private _vectors3;
  18821. private _vectors4;
  18822. private _matrices;
  18823. private _matrices3x3;
  18824. private _matrices2x2;
  18825. private _vectors2Arrays;
  18826. private _vectors3Arrays;
  18827. private _vectors4Arrays;
  18828. private _cachedWorldViewMatrix;
  18829. private _cachedWorldViewProjectionMatrix;
  18830. private _renderId;
  18831. /**
  18832. * Instantiate a new shader material.
  18833. * 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.
  18834. * This returned material effects how the mesh will look based on the code in the shaders.
  18835. * @see http://doc.babylonjs.com/how_to/shader_material
  18836. * @param name Define the name of the material in the scene
  18837. * @param scene Define the scene the material belongs to
  18838. * @param shaderPath Defines the route to the shader code in one of three ways:
  18839. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18840. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18841. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18842. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18843. * @param options Define the options used to create the shader
  18844. */
  18845. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18846. /**
  18847. * Gets the options used to compile the shader.
  18848. * They can be modified to trigger a new compilation
  18849. */
  18850. readonly options: IShaderMaterialOptions;
  18851. /**
  18852. * Gets the current class name of the material e.g. "ShaderMaterial"
  18853. * Mainly use in serialization.
  18854. * @returns the class name
  18855. */
  18856. getClassName(): string;
  18857. /**
  18858. * Specifies if the material will require alpha blending
  18859. * @returns a boolean specifying if alpha blending is needed
  18860. */
  18861. needAlphaBlending(): boolean;
  18862. /**
  18863. * Specifies if this material should be rendered in alpha test mode
  18864. * @returns a boolean specifying if an alpha test is needed.
  18865. */
  18866. needAlphaTesting(): boolean;
  18867. private _checkUniform;
  18868. /**
  18869. * Set a texture in the shader.
  18870. * @param name Define the name of the uniform samplers as defined in the shader
  18871. * @param texture Define the texture to bind to this sampler
  18872. * @return the material itself allowing "fluent" like uniform updates
  18873. */
  18874. setTexture(name: string, texture: Texture): ShaderMaterial;
  18875. /**
  18876. * Set a texture array in the shader.
  18877. * @param name Define the name of the uniform sampler array as defined in the shader
  18878. * @param textures Define the list of textures to bind to this sampler
  18879. * @return the material itself allowing "fluent" like uniform updates
  18880. */
  18881. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18882. /**
  18883. * Set a float in the shader.
  18884. * @param name Define the name of the uniform as defined in the shader
  18885. * @param value Define the value to give to the uniform
  18886. * @return the material itself allowing "fluent" like uniform updates
  18887. */
  18888. setFloat(name: string, value: number): ShaderMaterial;
  18889. /**
  18890. * Set a int in the shader.
  18891. * @param name Define the name of the uniform as defined in the shader
  18892. * @param value Define the value to give to the uniform
  18893. * @return the material itself allowing "fluent" like uniform updates
  18894. */
  18895. setInt(name: string, value: number): ShaderMaterial;
  18896. /**
  18897. * Set an array of floats in the shader.
  18898. * @param name Define the name of the uniform as defined in the shader
  18899. * @param value Define the value to give to the uniform
  18900. * @return the material itself allowing "fluent" like uniform updates
  18901. */
  18902. setFloats(name: string, value: number[]): ShaderMaterial;
  18903. /**
  18904. * Set a vec3 in the shader from a Color3.
  18905. * @param name Define the name of the uniform as defined in the shader
  18906. * @param value Define the value to give to the uniform
  18907. * @return the material itself allowing "fluent" like uniform updates
  18908. */
  18909. setColor3(name: string, value: Color3): ShaderMaterial;
  18910. /**
  18911. * Set a vec3 array in the shader from a Color3 array.
  18912. * @param name Define the name of the uniform as defined in the shader
  18913. * @param value Define the value to give to the uniform
  18914. * @return the material itself allowing "fluent" like uniform updates
  18915. */
  18916. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18917. /**
  18918. * Set a vec4 in the shader from a Color4.
  18919. * @param name Define the name of the uniform as defined in the shader
  18920. * @param value Define the value to give to the uniform
  18921. * @return the material itself allowing "fluent" like uniform updates
  18922. */
  18923. setColor4(name: string, value: Color4): ShaderMaterial;
  18924. /**
  18925. * Set a vec4 array in the shader from a Color4 array.
  18926. * @param name Define the name of the uniform as defined in the shader
  18927. * @param value Define the value to give to the uniform
  18928. * @return the material itself allowing "fluent" like uniform updates
  18929. */
  18930. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18931. /**
  18932. * Set a vec2 in the shader from a Vector2.
  18933. * @param name Define the name of the uniform as defined in the shader
  18934. * @param value Define the value to give to the uniform
  18935. * @return the material itself allowing "fluent" like uniform updates
  18936. */
  18937. setVector2(name: string, value: Vector2): ShaderMaterial;
  18938. /**
  18939. * Set a vec3 in the shader from a Vector3.
  18940. * @param name Define the name of the uniform as defined in the shader
  18941. * @param value Define the value to give to the uniform
  18942. * @return the material itself allowing "fluent" like uniform updates
  18943. */
  18944. setVector3(name: string, value: Vector3): ShaderMaterial;
  18945. /**
  18946. * Set a vec4 in the shader from a Vector4.
  18947. * @param name Define the name of the uniform as defined in the shader
  18948. * @param value Define the value to give to the uniform
  18949. * @return the material itself allowing "fluent" like uniform updates
  18950. */
  18951. setVector4(name: string, value: Vector4): ShaderMaterial;
  18952. /**
  18953. * Set a mat4 in the shader from a Matrix.
  18954. * @param name Define the name of the uniform as defined in the shader
  18955. * @param value Define the value to give to the uniform
  18956. * @return the material itself allowing "fluent" like uniform updates
  18957. */
  18958. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18959. /**
  18960. * Set a mat3 in the shader from a Float32Array.
  18961. * @param name Define the name of the uniform as defined in the shader
  18962. * @param value Define the value to give to the uniform
  18963. * @return the material itself allowing "fluent" like uniform updates
  18964. */
  18965. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18966. /**
  18967. * Set a mat2 in the shader from a Float32Array.
  18968. * @param name Define the name of the uniform as defined in the shader
  18969. * @param value Define the value to give to the uniform
  18970. * @return the material itself allowing "fluent" like uniform updates
  18971. */
  18972. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18973. /**
  18974. * Set a vec2 array in the shader from a number array.
  18975. * @param name Define the name of the uniform as defined in the shader
  18976. * @param value Define the value to give to the uniform
  18977. * @return the material itself allowing "fluent" like uniform updates
  18978. */
  18979. setArray2(name: string, value: number[]): ShaderMaterial;
  18980. /**
  18981. * Set a vec3 array in the shader from a number array.
  18982. * @param name Define the name of the uniform as defined in the shader
  18983. * @param value Define the value to give to the uniform
  18984. * @return the material itself allowing "fluent" like uniform updates
  18985. */
  18986. setArray3(name: string, value: number[]): ShaderMaterial;
  18987. /**
  18988. * Set a vec4 array in the shader from a number array.
  18989. * @param name Define the name of the uniform as defined in the shader
  18990. * @param value Define the value to give to the uniform
  18991. * @return the material itself allowing "fluent" like uniform updates
  18992. */
  18993. setArray4(name: string, value: number[]): ShaderMaterial;
  18994. private _checkCache;
  18995. /**
  18996. * Specifies that the submesh is ready to be used
  18997. * @param mesh defines the mesh to check
  18998. * @param subMesh defines which submesh to check
  18999. * @param useInstances specifies that instances should be used
  19000. * @returns a boolean indicating that the submesh is ready or not
  19001. */
  19002. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19003. /**
  19004. * Checks if the material is ready to render the requested mesh
  19005. * @param mesh Define the mesh to render
  19006. * @param useInstances Define whether or not the material is used with instances
  19007. * @returns true if ready, otherwise false
  19008. */
  19009. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19010. /**
  19011. * Binds the world matrix to the material
  19012. * @param world defines the world transformation matrix
  19013. */
  19014. bindOnlyWorldMatrix(world: Matrix): void;
  19015. /**
  19016. * Binds the material to the mesh
  19017. * @param world defines the world transformation matrix
  19018. * @param mesh defines the mesh to bind the material to
  19019. */
  19020. bind(world: Matrix, mesh?: Mesh): void;
  19021. /**
  19022. * Gets the active textures from the material
  19023. * @returns an array of textures
  19024. */
  19025. getActiveTextures(): BaseTexture[];
  19026. /**
  19027. * Specifies if the material uses a texture
  19028. * @param texture defines the texture to check against the material
  19029. * @returns a boolean specifying if the material uses the texture
  19030. */
  19031. hasTexture(texture: BaseTexture): boolean;
  19032. /**
  19033. * Makes a duplicate of the material, and gives it a new name
  19034. * @param name defines the new name for the duplicated material
  19035. * @returns the cloned material
  19036. */
  19037. clone(name: string): ShaderMaterial;
  19038. /**
  19039. * Disposes the material
  19040. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19041. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19042. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19043. */
  19044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19045. /**
  19046. * Serializes this material in a JSON representation
  19047. * @returns the serialized material object
  19048. */
  19049. serialize(): any;
  19050. /**
  19051. * Creates a shader material from parsed shader material data
  19052. * @param source defines the JSON represnetation of the material
  19053. * @param scene defines the hosting scene
  19054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19055. * @returns a new material
  19056. */
  19057. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19058. }
  19059. }
  19060. declare module BABYLON {
  19061. /** @hidden */
  19062. export var colorPixelShader: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module BABYLON {
  19068. /** @hidden */
  19069. export var colorVertexShader: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module BABYLON {
  19075. /**
  19076. * Line mesh
  19077. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19078. */
  19079. export class LinesMesh extends Mesh {
  19080. /**
  19081. * If vertex color should be applied to the mesh
  19082. */
  19083. readonly useVertexColor?: boolean | undefined;
  19084. /**
  19085. * If vertex alpha should be applied to the mesh
  19086. */
  19087. readonly useVertexAlpha?: boolean | undefined;
  19088. /**
  19089. * Color of the line (Default: White)
  19090. */
  19091. color: Color3;
  19092. /**
  19093. * Alpha of the line (Default: 1)
  19094. */
  19095. alpha: number;
  19096. /**
  19097. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19098. * This margin is expressed in world space coordinates, so its value may vary.
  19099. * Default value is 0.1
  19100. */
  19101. intersectionThreshold: number;
  19102. private _colorShader;
  19103. private color4;
  19104. /**
  19105. * Creates a new LinesMesh
  19106. * @param name defines the name
  19107. * @param scene defines the hosting scene
  19108. * @param parent defines the parent mesh if any
  19109. * @param source defines the optional source LinesMesh used to clone data from
  19110. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19111. * When false, achieved by calling a clone(), also passing False.
  19112. * This will make creation of children, recursive.
  19113. * @param useVertexColor defines if this LinesMesh supports vertex color
  19114. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19115. */
  19116. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19117. /**
  19118. * If vertex color should be applied to the mesh
  19119. */
  19120. useVertexColor?: boolean | undefined,
  19121. /**
  19122. * If vertex alpha should be applied to the mesh
  19123. */
  19124. useVertexAlpha?: boolean | undefined);
  19125. private _addClipPlaneDefine;
  19126. private _removeClipPlaneDefine;
  19127. isReady(): boolean;
  19128. /**
  19129. * Returns the string "LineMesh"
  19130. */
  19131. getClassName(): string;
  19132. /**
  19133. * @hidden
  19134. */
  19135. /**
  19136. * @hidden
  19137. */
  19138. material: Material;
  19139. /**
  19140. * @hidden
  19141. */
  19142. readonly checkCollisions: boolean;
  19143. /** @hidden */
  19144. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19145. /** @hidden */
  19146. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19147. /**
  19148. * Disposes of the line mesh
  19149. * @param doNotRecurse If children should be disposed
  19150. */
  19151. dispose(doNotRecurse?: boolean): void;
  19152. /**
  19153. * Returns a new LineMesh object cloned from the current one.
  19154. */
  19155. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19156. /**
  19157. * Creates a new InstancedLinesMesh object from the mesh model.
  19158. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19159. * @param name defines the name of the new instance
  19160. * @returns a new InstancedLinesMesh
  19161. */
  19162. createInstance(name: string): InstancedLinesMesh;
  19163. }
  19164. /**
  19165. * Creates an instance based on a source LinesMesh
  19166. */
  19167. export class InstancedLinesMesh extends InstancedMesh {
  19168. /**
  19169. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19170. * This margin is expressed in world space coordinates, so its value may vary.
  19171. * Initilized with the intersectionThreshold value of the source LinesMesh
  19172. */
  19173. intersectionThreshold: number;
  19174. constructor(name: string, source: LinesMesh);
  19175. /**
  19176. * Returns the string "InstancedLinesMesh".
  19177. */
  19178. getClassName(): string;
  19179. }
  19180. }
  19181. declare module BABYLON {
  19182. /** @hidden */
  19183. export var linePixelShader: {
  19184. name: string;
  19185. shader: string;
  19186. };
  19187. }
  19188. declare module BABYLON {
  19189. /** @hidden */
  19190. export var lineVertexShader: {
  19191. name: string;
  19192. shader: string;
  19193. };
  19194. }
  19195. declare module BABYLON {
  19196. interface AbstractMesh {
  19197. /**
  19198. * Gets the edgesRenderer associated with the mesh
  19199. */
  19200. edgesRenderer: Nullable<EdgesRenderer>;
  19201. }
  19202. interface LinesMesh {
  19203. /**
  19204. * Enables the edge rendering mode on the mesh.
  19205. * This mode makes the mesh edges visible
  19206. * @param epsilon defines the maximal distance between two angles to detect a face
  19207. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19208. * @returns the currentAbstractMesh
  19209. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19210. */
  19211. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19212. }
  19213. interface InstancedLinesMesh {
  19214. /**
  19215. * Enables the edge rendering mode on the mesh.
  19216. * This mode makes the mesh edges visible
  19217. * @param epsilon defines the maximal distance between two angles to detect a face
  19218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19219. * @returns the current InstancedLinesMesh
  19220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19221. */
  19222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19223. }
  19224. /**
  19225. * Defines the minimum contract an Edges renderer should follow.
  19226. */
  19227. export interface IEdgesRenderer extends IDisposable {
  19228. /**
  19229. * Gets or sets a boolean indicating if the edgesRenderer is active
  19230. */
  19231. isEnabled: boolean;
  19232. /**
  19233. * Renders the edges of the attached mesh,
  19234. */
  19235. render(): void;
  19236. /**
  19237. * Checks wether or not the edges renderer is ready to render.
  19238. * @return true if ready, otherwise false.
  19239. */
  19240. isReady(): boolean;
  19241. }
  19242. /**
  19243. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19244. */
  19245. export class EdgesRenderer implements IEdgesRenderer {
  19246. /**
  19247. * Define the size of the edges with an orthographic camera
  19248. */
  19249. edgesWidthScalerForOrthographic: number;
  19250. /**
  19251. * Define the size of the edges with a perspective camera
  19252. */
  19253. edgesWidthScalerForPerspective: number;
  19254. protected _source: AbstractMesh;
  19255. protected _linesPositions: number[];
  19256. protected _linesNormals: number[];
  19257. protected _linesIndices: number[];
  19258. protected _epsilon: number;
  19259. protected _indicesCount: number;
  19260. protected _lineShader: ShaderMaterial;
  19261. protected _ib: DataBuffer;
  19262. protected _buffers: {
  19263. [key: string]: Nullable<VertexBuffer>;
  19264. };
  19265. protected _checkVerticesInsteadOfIndices: boolean;
  19266. private _meshRebuildObserver;
  19267. private _meshDisposeObserver;
  19268. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19269. isEnabled: boolean;
  19270. /**
  19271. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19272. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19273. * @param source Mesh used to create edges
  19274. * @param epsilon sum of angles in adjacency to check for edge
  19275. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19276. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19277. */
  19278. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19279. protected _prepareRessources(): void;
  19280. /** @hidden */
  19281. _rebuild(): void;
  19282. /**
  19283. * Releases the required resources for the edges renderer
  19284. */
  19285. dispose(): void;
  19286. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19287. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19288. /**
  19289. * Checks if the pair of p0 and p1 is en edge
  19290. * @param faceIndex
  19291. * @param edge
  19292. * @param faceNormals
  19293. * @param p0
  19294. * @param p1
  19295. * @private
  19296. */
  19297. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19298. /**
  19299. * push line into the position, normal and index buffer
  19300. * @protected
  19301. */
  19302. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19303. /**
  19304. * Generates lines edges from adjacencjes
  19305. * @private
  19306. */
  19307. _generateEdgesLines(): void;
  19308. /**
  19309. * Checks wether or not the edges renderer is ready to render.
  19310. * @return true if ready, otherwise false.
  19311. */
  19312. isReady(): boolean;
  19313. /**
  19314. * Renders the edges of the attached mesh,
  19315. */
  19316. render(): void;
  19317. }
  19318. /**
  19319. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19320. */
  19321. export class LineEdgesRenderer extends EdgesRenderer {
  19322. /**
  19323. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19324. * @param source LineMesh used to generate edges
  19325. * @param epsilon not important (specified angle for edge detection)
  19326. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19327. */
  19328. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19329. /**
  19330. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19331. */
  19332. _generateEdgesLines(): void;
  19333. }
  19334. }
  19335. declare module BABYLON {
  19336. /**
  19337. * This represents the object necessary to create a rendering group.
  19338. * This is exclusively used and created by the rendering manager.
  19339. * To modify the behavior, you use the available helpers in your scene or meshes.
  19340. * @hidden
  19341. */
  19342. export class RenderingGroup {
  19343. index: number;
  19344. private static _zeroVector;
  19345. private _scene;
  19346. private _opaqueSubMeshes;
  19347. private _transparentSubMeshes;
  19348. private _alphaTestSubMeshes;
  19349. private _depthOnlySubMeshes;
  19350. private _particleSystems;
  19351. private _spriteManagers;
  19352. private _opaqueSortCompareFn;
  19353. private _alphaTestSortCompareFn;
  19354. private _transparentSortCompareFn;
  19355. private _renderOpaque;
  19356. private _renderAlphaTest;
  19357. private _renderTransparent;
  19358. /** @hidden */
  19359. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19360. onBeforeTransparentRendering: () => void;
  19361. /**
  19362. * Set the opaque sort comparison function.
  19363. * If null the sub meshes will be render in the order they were created
  19364. */
  19365. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19366. /**
  19367. * Set the alpha test sort comparison function.
  19368. * If null the sub meshes will be render in the order they were created
  19369. */
  19370. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19371. /**
  19372. * Set the transparent sort comparison function.
  19373. * If null the sub meshes will be render in the order they were created
  19374. */
  19375. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19376. /**
  19377. * Creates a new rendering group.
  19378. * @param index The rendering group index
  19379. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19380. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19381. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19382. */
  19383. 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>);
  19384. /**
  19385. * Render all the sub meshes contained in the group.
  19386. * @param customRenderFunction Used to override the default render behaviour of the group.
  19387. * @returns true if rendered some submeshes.
  19388. */
  19389. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19390. /**
  19391. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19392. * @param subMeshes The submeshes to render
  19393. */
  19394. private renderOpaqueSorted;
  19395. /**
  19396. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19397. * @param subMeshes The submeshes to render
  19398. */
  19399. private renderAlphaTestSorted;
  19400. /**
  19401. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19402. * @param subMeshes The submeshes to render
  19403. */
  19404. private renderTransparentSorted;
  19405. /**
  19406. * Renders the submeshes in a specified order.
  19407. * @param subMeshes The submeshes to sort before render
  19408. * @param sortCompareFn The comparison function use to sort
  19409. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19410. * @param transparent Specifies to activate blending if true
  19411. */
  19412. private static renderSorted;
  19413. /**
  19414. * Renders the submeshes in the order they were dispatched (no sort applied).
  19415. * @param subMeshes The submeshes to render
  19416. */
  19417. private static renderUnsorted;
  19418. /**
  19419. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19420. * are rendered back to front if in the same alpha index.
  19421. *
  19422. * @param a The first submesh
  19423. * @param b The second submesh
  19424. * @returns The result of the comparison
  19425. */
  19426. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19427. /**
  19428. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19429. * are rendered back to front.
  19430. *
  19431. * @param a The first submesh
  19432. * @param b The second submesh
  19433. * @returns The result of the comparison
  19434. */
  19435. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19436. /**
  19437. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19438. * are rendered front to back (prevent overdraw).
  19439. *
  19440. * @param a The first submesh
  19441. * @param b The second submesh
  19442. * @returns The result of the comparison
  19443. */
  19444. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19445. /**
  19446. * Resets the different lists of submeshes to prepare a new frame.
  19447. */
  19448. prepare(): void;
  19449. dispose(): void;
  19450. /**
  19451. * Inserts the submesh in its correct queue depending on its material.
  19452. * @param subMesh The submesh to dispatch
  19453. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19454. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19455. */
  19456. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19457. dispatchSprites(spriteManager: ISpriteManager): void;
  19458. dispatchParticles(particleSystem: IParticleSystem): void;
  19459. private _renderParticles;
  19460. private _renderSprites;
  19461. }
  19462. }
  19463. declare module BABYLON {
  19464. /**
  19465. * Interface describing the different options available in the rendering manager
  19466. * regarding Auto Clear between groups.
  19467. */
  19468. export interface IRenderingManagerAutoClearSetup {
  19469. /**
  19470. * Defines whether or not autoclear is enable.
  19471. */
  19472. autoClear: boolean;
  19473. /**
  19474. * Defines whether or not to autoclear the depth buffer.
  19475. */
  19476. depth: boolean;
  19477. /**
  19478. * Defines whether or not to autoclear the stencil buffer.
  19479. */
  19480. stencil: boolean;
  19481. }
  19482. /**
  19483. * This class is used by the onRenderingGroupObservable
  19484. */
  19485. export class RenderingGroupInfo {
  19486. /**
  19487. * The Scene that being rendered
  19488. */
  19489. scene: Scene;
  19490. /**
  19491. * The camera currently used for the rendering pass
  19492. */
  19493. camera: Nullable<Camera>;
  19494. /**
  19495. * The ID of the renderingGroup being processed
  19496. */
  19497. renderingGroupId: number;
  19498. }
  19499. /**
  19500. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19501. * It is enable to manage the different groups as well as the different necessary sort functions.
  19502. * This should not be used directly aside of the few static configurations
  19503. */
  19504. export class RenderingManager {
  19505. /**
  19506. * The max id used for rendering groups (not included)
  19507. */
  19508. static MAX_RENDERINGGROUPS: number;
  19509. /**
  19510. * The min id used for rendering groups (included)
  19511. */
  19512. static MIN_RENDERINGGROUPS: number;
  19513. /**
  19514. * Used to globally prevent autoclearing scenes.
  19515. */
  19516. static AUTOCLEAR: boolean;
  19517. /**
  19518. * @hidden
  19519. */
  19520. _useSceneAutoClearSetup: boolean;
  19521. private _scene;
  19522. private _renderingGroups;
  19523. private _depthStencilBufferAlreadyCleaned;
  19524. private _autoClearDepthStencil;
  19525. private _customOpaqueSortCompareFn;
  19526. private _customAlphaTestSortCompareFn;
  19527. private _customTransparentSortCompareFn;
  19528. private _renderingGroupInfo;
  19529. /**
  19530. * Instantiates a new rendering group for a particular scene
  19531. * @param scene Defines the scene the groups belongs to
  19532. */
  19533. constructor(scene: Scene);
  19534. private _clearDepthStencilBuffer;
  19535. /**
  19536. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19537. * @hidden
  19538. */
  19539. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19540. /**
  19541. * Resets the different information of the group to prepare a new frame
  19542. * @hidden
  19543. */
  19544. reset(): void;
  19545. /**
  19546. * Dispose and release the group and its associated resources.
  19547. * @hidden
  19548. */
  19549. dispose(): void;
  19550. /**
  19551. * Clear the info related to rendering groups preventing retention points during dispose.
  19552. */
  19553. freeRenderingGroups(): void;
  19554. private _prepareRenderingGroup;
  19555. /**
  19556. * Add a sprite manager to the rendering manager in order to render it this frame.
  19557. * @param spriteManager Define the sprite manager to render
  19558. */
  19559. dispatchSprites(spriteManager: ISpriteManager): void;
  19560. /**
  19561. * Add a particle system to the rendering manager in order to render it this frame.
  19562. * @param particleSystem Define the particle system to render
  19563. */
  19564. dispatchParticles(particleSystem: IParticleSystem): void;
  19565. /**
  19566. * Add a submesh to the manager in order to render it this frame
  19567. * @param subMesh The submesh to dispatch
  19568. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19569. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19570. */
  19571. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19572. /**
  19573. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19574. * This allowed control for front to back rendering or reversly depending of the special needs.
  19575. *
  19576. * @param renderingGroupId The rendering group id corresponding to its index
  19577. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19578. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19579. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19580. */
  19581. 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;
  19582. /**
  19583. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19584. *
  19585. * @param renderingGroupId The rendering group id corresponding to its index
  19586. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19587. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19588. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19589. */
  19590. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19591. /**
  19592. * Gets the current auto clear configuration for one rendering group of the rendering
  19593. * manager.
  19594. * @param index the rendering group index to get the information for
  19595. * @returns The auto clear setup for the requested rendering group
  19596. */
  19597. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19598. }
  19599. }
  19600. declare module BABYLON {
  19601. /**
  19602. * This Helps creating a texture that will be created from a camera in your scene.
  19603. * It is basically a dynamic texture that could be used to create special effects for instance.
  19604. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19605. */
  19606. export class RenderTargetTexture extends Texture {
  19607. isCube: boolean;
  19608. /**
  19609. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19610. */
  19611. static readonly REFRESHRATE_RENDER_ONCE: number;
  19612. /**
  19613. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19614. */
  19615. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19616. /**
  19617. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19618. * the central point of your effect and can save a lot of performances.
  19619. */
  19620. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19621. /**
  19622. * Use this predicate to dynamically define the list of mesh you want to render.
  19623. * If set, the renderList property will be overwritten.
  19624. */
  19625. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19626. private _renderList;
  19627. /**
  19628. * Use this list to define the list of mesh you want to render.
  19629. */
  19630. renderList: Nullable<Array<AbstractMesh>>;
  19631. private _hookArray;
  19632. /**
  19633. * Define if particles should be rendered in your texture.
  19634. */
  19635. renderParticles: boolean;
  19636. /**
  19637. * Define if sprites should be rendered in your texture.
  19638. */
  19639. renderSprites: boolean;
  19640. /**
  19641. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19642. */
  19643. coordinatesMode: number;
  19644. /**
  19645. * Define the camera used to render the texture.
  19646. */
  19647. activeCamera: Nullable<Camera>;
  19648. /**
  19649. * Override the render function of the texture with your own one.
  19650. */
  19651. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19652. /**
  19653. * Define if camera post processes should be use while rendering the texture.
  19654. */
  19655. useCameraPostProcesses: boolean;
  19656. /**
  19657. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19658. */
  19659. ignoreCameraViewport: boolean;
  19660. private _postProcessManager;
  19661. private _postProcesses;
  19662. private _resizeObserver;
  19663. /**
  19664. * An event triggered when the texture is unbind.
  19665. */
  19666. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19667. /**
  19668. * An event triggered when the texture is unbind.
  19669. */
  19670. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19671. private _onAfterUnbindObserver;
  19672. /**
  19673. * Set a after unbind callback in the texture.
  19674. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19675. */
  19676. onAfterUnbind: () => void;
  19677. /**
  19678. * An event triggered before rendering the texture
  19679. */
  19680. onBeforeRenderObservable: Observable<number>;
  19681. private _onBeforeRenderObserver;
  19682. /**
  19683. * Set a before render callback in the texture.
  19684. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19685. */
  19686. onBeforeRender: (faceIndex: number) => void;
  19687. /**
  19688. * An event triggered after rendering the texture
  19689. */
  19690. onAfterRenderObservable: Observable<number>;
  19691. private _onAfterRenderObserver;
  19692. /**
  19693. * Set a after render callback in the texture.
  19694. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19695. */
  19696. onAfterRender: (faceIndex: number) => void;
  19697. /**
  19698. * An event triggered after the texture clear
  19699. */
  19700. onClearObservable: Observable<Engine>;
  19701. private _onClearObserver;
  19702. /**
  19703. * Set a clear callback in the texture.
  19704. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19705. */
  19706. onClear: (Engine: Engine) => void;
  19707. /**
  19708. * An event triggered when the texture is resized.
  19709. */
  19710. onResizeObservable: Observable<RenderTargetTexture>;
  19711. /**
  19712. * Define the clear color of the Render Target if it should be different from the scene.
  19713. */
  19714. clearColor: Color4;
  19715. protected _size: number | {
  19716. width: number;
  19717. height: number;
  19718. };
  19719. protected _initialSizeParameter: number | {
  19720. width: number;
  19721. height: number;
  19722. } | {
  19723. ratio: number;
  19724. };
  19725. protected _sizeRatio: Nullable<number>;
  19726. /** @hidden */
  19727. _generateMipMaps: boolean;
  19728. protected _renderingManager: RenderingManager;
  19729. /** @hidden */
  19730. _waitingRenderList: string[];
  19731. protected _doNotChangeAspectRatio: boolean;
  19732. protected _currentRefreshId: number;
  19733. protected _refreshRate: number;
  19734. protected _textureMatrix: Matrix;
  19735. protected _samples: number;
  19736. protected _renderTargetOptions: RenderTargetCreationOptions;
  19737. /**
  19738. * Gets render target creation options that were used.
  19739. */
  19740. readonly renderTargetOptions: RenderTargetCreationOptions;
  19741. protected _engine: Engine;
  19742. protected _onRatioRescale(): void;
  19743. /**
  19744. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19745. * It must define where the camera used to render the texture is set
  19746. */
  19747. boundingBoxPosition: Vector3;
  19748. private _boundingBoxSize;
  19749. /**
  19750. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19751. * When defined, the cubemap will switch to local mode
  19752. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19753. * @example https://www.babylonjs-playground.com/#RNASML
  19754. */
  19755. boundingBoxSize: Vector3;
  19756. /**
  19757. * In case the RTT has been created with a depth texture, get the associated
  19758. * depth texture.
  19759. * Otherwise, return null.
  19760. */
  19761. depthStencilTexture: Nullable<InternalTexture>;
  19762. /**
  19763. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19764. * or used a shadow, depth texture...
  19765. * @param name The friendly name of the texture
  19766. * @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)
  19767. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19768. * @param generateMipMaps True if mip maps need to be generated after render.
  19769. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19770. * @param type The type of the buffer in the RTT (int, half float, float...)
  19771. * @param isCube True if a cube texture needs to be created
  19772. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19773. * @param generateDepthBuffer True to generate a depth buffer
  19774. * @param generateStencilBuffer True to generate a stencil buffer
  19775. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19776. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19777. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19778. */
  19779. constructor(name: string, size: number | {
  19780. width: number;
  19781. height: number;
  19782. } | {
  19783. ratio: number;
  19784. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19785. /**
  19786. * Creates a depth stencil texture.
  19787. * This is only available in WebGL 2 or with the depth texture extension available.
  19788. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19789. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19790. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19791. */
  19792. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19793. private _processSizeParameter;
  19794. /**
  19795. * Define the number of samples to use in case of MSAA.
  19796. * It defaults to one meaning no MSAA has been enabled.
  19797. */
  19798. samples: number;
  19799. /**
  19800. * Resets the refresh counter of the texture and start bak from scratch.
  19801. * Could be useful to regenerate the texture if it is setup to render only once.
  19802. */
  19803. resetRefreshCounter(): void;
  19804. /**
  19805. * Define the refresh rate of the texture or the rendering frequency.
  19806. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19807. */
  19808. refreshRate: number;
  19809. /**
  19810. * Adds a post process to the render target rendering passes.
  19811. * @param postProcess define the post process to add
  19812. */
  19813. addPostProcess(postProcess: PostProcess): void;
  19814. /**
  19815. * Clear all the post processes attached to the render target
  19816. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19817. */
  19818. clearPostProcesses(dispose?: boolean): void;
  19819. /**
  19820. * Remove one of the post process from the list of attached post processes to the texture
  19821. * @param postProcess define the post process to remove from the list
  19822. */
  19823. removePostProcess(postProcess: PostProcess): void;
  19824. /** @hidden */
  19825. _shouldRender(): boolean;
  19826. /**
  19827. * Gets the actual render size of the texture.
  19828. * @returns the width of the render size
  19829. */
  19830. getRenderSize(): number;
  19831. /**
  19832. * Gets the actual render width of the texture.
  19833. * @returns the width of the render size
  19834. */
  19835. getRenderWidth(): number;
  19836. /**
  19837. * Gets the actual render height of the texture.
  19838. * @returns the height of the render size
  19839. */
  19840. getRenderHeight(): number;
  19841. /**
  19842. * Get if the texture can be rescaled or not.
  19843. */
  19844. readonly canRescale: boolean;
  19845. /**
  19846. * Resize the texture using a ratio.
  19847. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19848. */
  19849. scale(ratio: number): void;
  19850. /**
  19851. * Get the texture reflection matrix used to rotate/transform the reflection.
  19852. * @returns the reflection matrix
  19853. */
  19854. getReflectionTextureMatrix(): Matrix;
  19855. /**
  19856. * Resize the texture to a new desired size.
  19857. * Be carrefull as it will recreate all the data in the new texture.
  19858. * @param size Define the new size. It can be:
  19859. * - a number for squared texture,
  19860. * - an object containing { width: number, height: number }
  19861. * - or an object containing a ratio { ratio: number }
  19862. */
  19863. resize(size: number | {
  19864. width: number;
  19865. height: number;
  19866. } | {
  19867. ratio: number;
  19868. }): void;
  19869. /**
  19870. * Renders all the objects from the render list into the texture.
  19871. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19872. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19873. */
  19874. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19875. private _bestReflectionRenderTargetDimension;
  19876. /**
  19877. * @hidden
  19878. * @param faceIndex face index to bind to if this is a cubetexture
  19879. */
  19880. _bindFrameBuffer(faceIndex?: number): void;
  19881. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19882. private renderToTarget;
  19883. /**
  19884. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19885. * This allowed control for front to back rendering or reversly depending of the special needs.
  19886. *
  19887. * @param renderingGroupId The rendering group id corresponding to its index
  19888. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19889. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19890. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19891. */
  19892. 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;
  19893. /**
  19894. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19895. *
  19896. * @param renderingGroupId The rendering group id corresponding to its index
  19897. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19898. */
  19899. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19900. /**
  19901. * Clones the texture.
  19902. * @returns the cloned texture
  19903. */
  19904. clone(): RenderTargetTexture;
  19905. /**
  19906. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19907. * @returns The JSON representation of the texture
  19908. */
  19909. serialize(): any;
  19910. /**
  19911. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19912. */
  19913. disposeFramebufferObjects(): void;
  19914. /**
  19915. * Dispose the texture and release its associated resources.
  19916. */
  19917. dispose(): void;
  19918. /** @hidden */
  19919. _rebuild(): void;
  19920. /**
  19921. * Clear the info related to rendering groups preventing retention point in material dispose.
  19922. */
  19923. freeRenderingGroups(): void;
  19924. /**
  19925. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19926. * @returns the view count
  19927. */
  19928. getViewCount(): number;
  19929. }
  19930. }
  19931. declare module BABYLON {
  19932. /**
  19933. * Base class for the main features of a material in Babylon.js
  19934. */
  19935. export class Material implements IAnimatable {
  19936. /**
  19937. * Returns the triangle fill mode
  19938. */
  19939. static readonly TriangleFillMode: number;
  19940. /**
  19941. * Returns the wireframe mode
  19942. */
  19943. static readonly WireFrameFillMode: number;
  19944. /**
  19945. * Returns the point fill mode
  19946. */
  19947. static readonly PointFillMode: number;
  19948. /**
  19949. * Returns the point list draw mode
  19950. */
  19951. static readonly PointListDrawMode: number;
  19952. /**
  19953. * Returns the line list draw mode
  19954. */
  19955. static readonly LineListDrawMode: number;
  19956. /**
  19957. * Returns the line loop draw mode
  19958. */
  19959. static readonly LineLoopDrawMode: number;
  19960. /**
  19961. * Returns the line strip draw mode
  19962. */
  19963. static readonly LineStripDrawMode: number;
  19964. /**
  19965. * Returns the triangle strip draw mode
  19966. */
  19967. static readonly TriangleStripDrawMode: number;
  19968. /**
  19969. * Returns the triangle fan draw mode
  19970. */
  19971. static readonly TriangleFanDrawMode: number;
  19972. /**
  19973. * Stores the clock-wise side orientation
  19974. */
  19975. static readonly ClockWiseSideOrientation: number;
  19976. /**
  19977. * Stores the counter clock-wise side orientation
  19978. */
  19979. static readonly CounterClockWiseSideOrientation: number;
  19980. /**
  19981. * The dirty texture flag value
  19982. */
  19983. static readonly TextureDirtyFlag: number;
  19984. /**
  19985. * The dirty light flag value
  19986. */
  19987. static readonly LightDirtyFlag: number;
  19988. /**
  19989. * The dirty fresnel flag value
  19990. */
  19991. static readonly FresnelDirtyFlag: number;
  19992. /**
  19993. * The dirty attribute flag value
  19994. */
  19995. static readonly AttributesDirtyFlag: number;
  19996. /**
  19997. * The dirty misc flag value
  19998. */
  19999. static readonly MiscDirtyFlag: number;
  20000. /**
  20001. * The all dirty flag value
  20002. */
  20003. static readonly AllDirtyFlag: number;
  20004. /**
  20005. * The ID of the material
  20006. */
  20007. id: string;
  20008. /**
  20009. * Gets or sets the unique id of the material
  20010. */
  20011. uniqueId: number;
  20012. /**
  20013. * The name of the material
  20014. */
  20015. name: string;
  20016. /**
  20017. * Gets or sets user defined metadata
  20018. */
  20019. metadata: any;
  20020. /**
  20021. * For internal use only. Please do not use.
  20022. */
  20023. reservedDataStore: any;
  20024. /**
  20025. * Specifies if the ready state should be checked on each call
  20026. */
  20027. checkReadyOnEveryCall: boolean;
  20028. /**
  20029. * Specifies if the ready state should be checked once
  20030. */
  20031. checkReadyOnlyOnce: boolean;
  20032. /**
  20033. * The state of the material
  20034. */
  20035. state: string;
  20036. /**
  20037. * The alpha value of the material
  20038. */
  20039. protected _alpha: number;
  20040. /**
  20041. * List of inspectable custom properties (used by the Inspector)
  20042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20043. */
  20044. inspectableCustomProperties: IInspectable[];
  20045. /**
  20046. * Sets the alpha value of the material
  20047. */
  20048. /**
  20049. * Gets the alpha value of the material
  20050. */
  20051. alpha: number;
  20052. /**
  20053. * Specifies if back face culling is enabled
  20054. */
  20055. protected _backFaceCulling: boolean;
  20056. /**
  20057. * Sets the back-face culling state
  20058. */
  20059. /**
  20060. * Gets the back-face culling state
  20061. */
  20062. backFaceCulling: boolean;
  20063. /**
  20064. * Stores the value for side orientation
  20065. */
  20066. sideOrientation: number;
  20067. /**
  20068. * Callback triggered when the material is compiled
  20069. */
  20070. onCompiled: Nullable<(effect: Effect) => void>;
  20071. /**
  20072. * Callback triggered when an error occurs
  20073. */
  20074. onError: Nullable<(effect: Effect, errors: string) => void>;
  20075. /**
  20076. * Callback triggered to get the render target textures
  20077. */
  20078. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20079. /**
  20080. * Gets a boolean indicating that current material needs to register RTT
  20081. */
  20082. readonly hasRenderTargetTextures: boolean;
  20083. /**
  20084. * Specifies if the material should be serialized
  20085. */
  20086. doNotSerialize: boolean;
  20087. /**
  20088. * @hidden
  20089. */
  20090. _storeEffectOnSubMeshes: boolean;
  20091. /**
  20092. * Stores the animations for the material
  20093. */
  20094. animations: Nullable<Array<Animation>>;
  20095. /**
  20096. * An event triggered when the material is disposed
  20097. */
  20098. onDisposeObservable: Observable<Material>;
  20099. /**
  20100. * An observer which watches for dispose events
  20101. */
  20102. private _onDisposeObserver;
  20103. private _onUnBindObservable;
  20104. /**
  20105. * Called during a dispose event
  20106. */
  20107. onDispose: () => void;
  20108. private _onBindObservable;
  20109. /**
  20110. * An event triggered when the material is bound
  20111. */
  20112. readonly onBindObservable: Observable<AbstractMesh>;
  20113. /**
  20114. * An observer which watches for bind events
  20115. */
  20116. private _onBindObserver;
  20117. /**
  20118. * Called during a bind event
  20119. */
  20120. onBind: (Mesh: AbstractMesh) => void;
  20121. /**
  20122. * An event triggered when the material is unbound
  20123. */
  20124. readonly onUnBindObservable: Observable<Material>;
  20125. /**
  20126. * Stores the value of the alpha mode
  20127. */
  20128. private _alphaMode;
  20129. /**
  20130. * Sets the value of the alpha mode.
  20131. *
  20132. * | Value | Type | Description |
  20133. * | --- | --- | --- |
  20134. * | 0 | ALPHA_DISABLE | |
  20135. * | 1 | ALPHA_ADD | |
  20136. * | 2 | ALPHA_COMBINE | |
  20137. * | 3 | ALPHA_SUBTRACT | |
  20138. * | 4 | ALPHA_MULTIPLY | |
  20139. * | 5 | ALPHA_MAXIMIZED | |
  20140. * | 6 | ALPHA_ONEONE | |
  20141. * | 7 | ALPHA_PREMULTIPLIED | |
  20142. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20143. * | 9 | ALPHA_INTERPOLATE | |
  20144. * | 10 | ALPHA_SCREENMODE | |
  20145. *
  20146. */
  20147. /**
  20148. * Gets the value of the alpha mode
  20149. */
  20150. alphaMode: number;
  20151. /**
  20152. * Stores the state of the need depth pre-pass value
  20153. */
  20154. private _needDepthPrePass;
  20155. /**
  20156. * Sets the need depth pre-pass value
  20157. */
  20158. /**
  20159. * Gets the depth pre-pass value
  20160. */
  20161. needDepthPrePass: boolean;
  20162. /**
  20163. * Specifies if depth writing should be disabled
  20164. */
  20165. disableDepthWrite: boolean;
  20166. /**
  20167. * Specifies if depth writing should be forced
  20168. */
  20169. forceDepthWrite: boolean;
  20170. /**
  20171. * Specifies if there should be a separate pass for culling
  20172. */
  20173. separateCullingPass: boolean;
  20174. /**
  20175. * Stores the state specifing if fog should be enabled
  20176. */
  20177. private _fogEnabled;
  20178. /**
  20179. * Sets the state for enabling fog
  20180. */
  20181. /**
  20182. * Gets the value of the fog enabled state
  20183. */
  20184. fogEnabled: boolean;
  20185. /**
  20186. * Stores the size of points
  20187. */
  20188. pointSize: number;
  20189. /**
  20190. * Stores the z offset value
  20191. */
  20192. zOffset: number;
  20193. /**
  20194. * Gets a value specifying if wireframe mode is enabled
  20195. */
  20196. /**
  20197. * Sets the state of wireframe mode
  20198. */
  20199. wireframe: boolean;
  20200. /**
  20201. * Gets the value specifying if point clouds are enabled
  20202. */
  20203. /**
  20204. * Sets the state of point cloud mode
  20205. */
  20206. pointsCloud: boolean;
  20207. /**
  20208. * Gets the material fill mode
  20209. */
  20210. /**
  20211. * Sets the material fill mode
  20212. */
  20213. fillMode: number;
  20214. /**
  20215. * @hidden
  20216. * Stores the effects for the material
  20217. */
  20218. _effect: Nullable<Effect>;
  20219. /**
  20220. * @hidden
  20221. * Specifies if the material was previously ready
  20222. */
  20223. _wasPreviouslyReady: boolean;
  20224. /**
  20225. * Specifies if uniform buffers should be used
  20226. */
  20227. private _useUBO;
  20228. /**
  20229. * Stores a reference to the scene
  20230. */
  20231. private _scene;
  20232. /**
  20233. * Stores the fill mode state
  20234. */
  20235. private _fillMode;
  20236. /**
  20237. * Specifies if the depth write state should be cached
  20238. */
  20239. private _cachedDepthWriteState;
  20240. /**
  20241. * Stores the uniform buffer
  20242. */
  20243. protected _uniformBuffer: UniformBuffer;
  20244. /** @hidden */
  20245. _indexInSceneMaterialArray: number;
  20246. /** @hidden */
  20247. meshMap: Nullable<{
  20248. [id: string]: AbstractMesh | undefined;
  20249. }>;
  20250. /**
  20251. * Creates a material instance
  20252. * @param name defines the name of the material
  20253. * @param scene defines the scene to reference
  20254. * @param doNotAdd specifies if the material should be added to the scene
  20255. */
  20256. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20257. /**
  20258. * Returns a string representation of the current material
  20259. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20260. * @returns a string with material information
  20261. */
  20262. toString(fullDetails?: boolean): string;
  20263. /**
  20264. * Gets the class name of the material
  20265. * @returns a string with the class name of the material
  20266. */
  20267. getClassName(): string;
  20268. /**
  20269. * Specifies if updates for the material been locked
  20270. */
  20271. readonly isFrozen: boolean;
  20272. /**
  20273. * Locks updates for the material
  20274. */
  20275. freeze(): void;
  20276. /**
  20277. * Unlocks updates for the material
  20278. */
  20279. unfreeze(): void;
  20280. /**
  20281. * Specifies if the material is ready to be used
  20282. * @param mesh defines the mesh to check
  20283. * @param useInstances specifies if instances should be used
  20284. * @returns a boolean indicating if the material is ready to be used
  20285. */
  20286. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20287. /**
  20288. * Specifies that the submesh is ready to be used
  20289. * @param mesh defines the mesh to check
  20290. * @param subMesh defines which submesh to check
  20291. * @param useInstances specifies that instances should be used
  20292. * @returns a boolean indicating that the submesh is ready or not
  20293. */
  20294. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20295. /**
  20296. * Returns the material effect
  20297. * @returns the effect associated with the material
  20298. */
  20299. getEffect(): Nullable<Effect>;
  20300. /**
  20301. * Returns the current scene
  20302. * @returns a Scene
  20303. */
  20304. getScene(): Scene;
  20305. /**
  20306. * Specifies if the material will require alpha blending
  20307. * @returns a boolean specifying if alpha blending is needed
  20308. */
  20309. needAlphaBlending(): boolean;
  20310. /**
  20311. * Specifies if the mesh will require alpha blending
  20312. * @param mesh defines the mesh to check
  20313. * @returns a boolean specifying if alpha blending is needed for the mesh
  20314. */
  20315. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20316. /**
  20317. * Specifies if this material should be rendered in alpha test mode
  20318. * @returns a boolean specifying if an alpha test is needed.
  20319. */
  20320. needAlphaTesting(): boolean;
  20321. /**
  20322. * Gets the texture used for the alpha test
  20323. * @returns the texture to use for alpha testing
  20324. */
  20325. getAlphaTestTexture(): Nullable<BaseTexture>;
  20326. /**
  20327. * Marks the material to indicate that it needs to be re-calculated
  20328. */
  20329. markDirty(): void;
  20330. /** @hidden */
  20331. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20332. /**
  20333. * Binds the material to the mesh
  20334. * @param world defines the world transformation matrix
  20335. * @param mesh defines the mesh to bind the material to
  20336. */
  20337. bind(world: Matrix, mesh?: Mesh): void;
  20338. /**
  20339. * Binds the submesh to the material
  20340. * @param world defines the world transformation matrix
  20341. * @param mesh defines the mesh containing the submesh
  20342. * @param subMesh defines the submesh to bind the material to
  20343. */
  20344. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20345. /**
  20346. * Binds the world matrix to the material
  20347. * @param world defines the world transformation matrix
  20348. */
  20349. bindOnlyWorldMatrix(world: Matrix): void;
  20350. /**
  20351. * Binds the scene's uniform buffer to the effect.
  20352. * @param effect defines the effect to bind to the scene uniform buffer
  20353. * @param sceneUbo defines the uniform buffer storing scene data
  20354. */
  20355. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20356. /**
  20357. * Binds the view matrix to the effect
  20358. * @param effect defines the effect to bind the view matrix to
  20359. */
  20360. bindView(effect: Effect): void;
  20361. /**
  20362. * Binds the view projection matrix to the effect
  20363. * @param effect defines the effect to bind the view projection matrix to
  20364. */
  20365. bindViewProjection(effect: Effect): void;
  20366. /**
  20367. * Specifies if material alpha testing should be turned on for the mesh
  20368. * @param mesh defines the mesh to check
  20369. */
  20370. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20371. /**
  20372. * Processes to execute after binding the material to a mesh
  20373. * @param mesh defines the rendered mesh
  20374. */
  20375. protected _afterBind(mesh?: Mesh): void;
  20376. /**
  20377. * Unbinds the material from the mesh
  20378. */
  20379. unbind(): void;
  20380. /**
  20381. * Gets the active textures from the material
  20382. * @returns an array of textures
  20383. */
  20384. getActiveTextures(): BaseTexture[];
  20385. /**
  20386. * Specifies if the material uses a texture
  20387. * @param texture defines the texture to check against the material
  20388. * @returns a boolean specifying if the material uses the texture
  20389. */
  20390. hasTexture(texture: BaseTexture): boolean;
  20391. /**
  20392. * Makes a duplicate of the material, and gives it a new name
  20393. * @param name defines the new name for the duplicated material
  20394. * @returns the cloned material
  20395. */
  20396. clone(name: string): Nullable<Material>;
  20397. /**
  20398. * Gets the meshes bound to the material
  20399. * @returns an array of meshes bound to the material
  20400. */
  20401. getBindedMeshes(): AbstractMesh[];
  20402. /**
  20403. * Force shader compilation
  20404. * @param mesh defines the mesh associated with this material
  20405. * @param onCompiled defines a function to execute once the material is compiled
  20406. * @param options defines the options to configure the compilation
  20407. */
  20408. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20409. clipPlane: boolean;
  20410. }>): void;
  20411. /**
  20412. * Force shader compilation
  20413. * @param mesh defines the mesh that will use this material
  20414. * @param options defines additional options for compiling the shaders
  20415. * @returns a promise that resolves when the compilation completes
  20416. */
  20417. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20418. clipPlane: boolean;
  20419. }>): Promise<void>;
  20420. private static readonly _AllDirtyCallBack;
  20421. private static readonly _ImageProcessingDirtyCallBack;
  20422. private static readonly _TextureDirtyCallBack;
  20423. private static readonly _FresnelDirtyCallBack;
  20424. private static readonly _MiscDirtyCallBack;
  20425. private static readonly _LightsDirtyCallBack;
  20426. private static readonly _AttributeDirtyCallBack;
  20427. private static _FresnelAndMiscDirtyCallBack;
  20428. private static _TextureAndMiscDirtyCallBack;
  20429. private static readonly _DirtyCallbackArray;
  20430. private static readonly _RunDirtyCallBacks;
  20431. /**
  20432. * Marks a define in the material to indicate that it needs to be re-computed
  20433. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20434. */
  20435. markAsDirty(flag: number): void;
  20436. /**
  20437. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20438. * @param func defines a function which checks material defines against the submeshes
  20439. */
  20440. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20441. /**
  20442. * Indicates that we need to re-calculated for all submeshes
  20443. */
  20444. protected _markAllSubMeshesAsAllDirty(): void;
  20445. /**
  20446. * Indicates that image processing needs to be re-calculated for all submeshes
  20447. */
  20448. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20449. /**
  20450. * Indicates that textures need to be re-calculated for all submeshes
  20451. */
  20452. protected _markAllSubMeshesAsTexturesDirty(): void;
  20453. /**
  20454. * Indicates that fresnel needs to be re-calculated for all submeshes
  20455. */
  20456. protected _markAllSubMeshesAsFresnelDirty(): void;
  20457. /**
  20458. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20459. */
  20460. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20461. /**
  20462. * Indicates that lights need to be re-calculated for all submeshes
  20463. */
  20464. protected _markAllSubMeshesAsLightsDirty(): void;
  20465. /**
  20466. * Indicates that attributes need to be re-calculated for all submeshes
  20467. */
  20468. protected _markAllSubMeshesAsAttributesDirty(): void;
  20469. /**
  20470. * Indicates that misc needs to be re-calculated for all submeshes
  20471. */
  20472. protected _markAllSubMeshesAsMiscDirty(): void;
  20473. /**
  20474. * Indicates that textures and misc need to be re-calculated for all submeshes
  20475. */
  20476. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20477. /**
  20478. * Disposes the material
  20479. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20480. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20481. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20482. */
  20483. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20484. /** @hidden */
  20485. private releaseVertexArrayObject;
  20486. /**
  20487. * Serializes this material
  20488. * @returns the serialized material object
  20489. */
  20490. serialize(): any;
  20491. /**
  20492. * Creates a material from parsed material data
  20493. * @param parsedMaterial defines parsed material data
  20494. * @param scene defines the hosting scene
  20495. * @param rootUrl defines the root URL to use to load textures
  20496. * @returns a new material
  20497. */
  20498. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20499. }
  20500. }
  20501. declare module BABYLON {
  20502. /**
  20503. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20504. * separate meshes. This can be use to improve performances.
  20505. * @see http://doc.babylonjs.com/how_to/multi_materials
  20506. */
  20507. export class MultiMaterial extends Material {
  20508. private _subMaterials;
  20509. /**
  20510. * Gets or Sets the list of Materials used within the multi material.
  20511. * They need to be ordered according to the submeshes order in the associated mesh
  20512. */
  20513. subMaterials: Nullable<Material>[];
  20514. /**
  20515. * Function used to align with Node.getChildren()
  20516. * @returns the list of Materials used within the multi material
  20517. */
  20518. getChildren(): Nullable<Material>[];
  20519. /**
  20520. * Instantiates a new Multi Material
  20521. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20522. * separate meshes. This can be use to improve performances.
  20523. * @see http://doc.babylonjs.com/how_to/multi_materials
  20524. * @param name Define the name in the scene
  20525. * @param scene Define the scene the material belongs to
  20526. */
  20527. constructor(name: string, scene: Scene);
  20528. private _hookArray;
  20529. /**
  20530. * Get one of the submaterial by its index in the submaterials array
  20531. * @param index The index to look the sub material at
  20532. * @returns The Material if the index has been defined
  20533. */
  20534. getSubMaterial(index: number): Nullable<Material>;
  20535. /**
  20536. * Get the list of active textures for the whole sub materials list.
  20537. * @returns All the textures that will be used during the rendering
  20538. */
  20539. getActiveTextures(): BaseTexture[];
  20540. /**
  20541. * Gets the current class name of the material e.g. "MultiMaterial"
  20542. * Mainly use in serialization.
  20543. * @returns the class name
  20544. */
  20545. getClassName(): string;
  20546. /**
  20547. * Checks if the material is ready to render the requested sub mesh
  20548. * @param mesh Define the mesh the submesh belongs to
  20549. * @param subMesh Define the sub mesh to look readyness for
  20550. * @param useInstances Define whether or not the material is used with instances
  20551. * @returns true if ready, otherwise false
  20552. */
  20553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20554. /**
  20555. * Clones the current material and its related sub materials
  20556. * @param name Define the name of the newly cloned material
  20557. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20558. * @returns the cloned material
  20559. */
  20560. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20561. /**
  20562. * Serializes the materials into a JSON representation.
  20563. * @returns the JSON representation
  20564. */
  20565. serialize(): any;
  20566. /**
  20567. * Dispose the material and release its associated resources
  20568. * @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)
  20569. * @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)
  20570. * @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)
  20571. */
  20572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20573. /**
  20574. * Creates a MultiMaterial from parsed MultiMaterial data.
  20575. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20576. * @param scene defines the hosting scene
  20577. * @returns a new MultiMaterial
  20578. */
  20579. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20580. }
  20581. }
  20582. declare module BABYLON {
  20583. /**
  20584. * Base class for submeshes
  20585. */
  20586. export class BaseSubMesh {
  20587. /** @hidden */
  20588. _materialDefines: Nullable<MaterialDefines>;
  20589. /** @hidden */
  20590. _materialEffect: Nullable<Effect>;
  20591. /**
  20592. * Gets associated effect
  20593. */
  20594. readonly effect: Nullable<Effect>;
  20595. /**
  20596. * Sets associated effect (effect used to render this submesh)
  20597. * @param effect defines the effect to associate with
  20598. * @param defines defines the set of defines used to compile this effect
  20599. */
  20600. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20601. }
  20602. /**
  20603. * Defines a subdivision inside a mesh
  20604. */
  20605. export class SubMesh extends BaseSubMesh implements ICullable {
  20606. /** the material index to use */
  20607. materialIndex: number;
  20608. /** vertex index start */
  20609. verticesStart: number;
  20610. /** vertices count */
  20611. verticesCount: number;
  20612. /** index start */
  20613. indexStart: number;
  20614. /** indices count */
  20615. indexCount: number;
  20616. /** @hidden */
  20617. _linesIndexCount: number;
  20618. private _mesh;
  20619. private _renderingMesh;
  20620. private _boundingInfo;
  20621. private _linesIndexBuffer;
  20622. /** @hidden */
  20623. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20624. /** @hidden */
  20625. _trianglePlanes: Plane[];
  20626. /** @hidden */
  20627. _lastColliderTransformMatrix: Nullable<Matrix>;
  20628. /** @hidden */
  20629. _renderId: number;
  20630. /** @hidden */
  20631. _alphaIndex: number;
  20632. /** @hidden */
  20633. _distanceToCamera: number;
  20634. /** @hidden */
  20635. _id: number;
  20636. private _currentMaterial;
  20637. /**
  20638. * Add a new submesh to a mesh
  20639. * @param materialIndex defines the material index to use
  20640. * @param verticesStart defines vertex index start
  20641. * @param verticesCount defines vertices count
  20642. * @param indexStart defines index start
  20643. * @param indexCount defines indices count
  20644. * @param mesh defines the parent mesh
  20645. * @param renderingMesh defines an optional rendering mesh
  20646. * @param createBoundingBox defines if bounding box should be created for this submesh
  20647. * @returns the new submesh
  20648. */
  20649. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20650. /**
  20651. * Creates a new submesh
  20652. * @param materialIndex defines the material index to use
  20653. * @param verticesStart defines vertex index start
  20654. * @param verticesCount defines vertices count
  20655. * @param indexStart defines index start
  20656. * @param indexCount defines indices count
  20657. * @param mesh defines the parent mesh
  20658. * @param renderingMesh defines an optional rendering mesh
  20659. * @param createBoundingBox defines if bounding box should be created for this submesh
  20660. */
  20661. constructor(
  20662. /** the material index to use */
  20663. materialIndex: number,
  20664. /** vertex index start */
  20665. verticesStart: number,
  20666. /** vertices count */
  20667. verticesCount: number,
  20668. /** index start */
  20669. indexStart: number,
  20670. /** indices count */
  20671. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20672. /**
  20673. * Returns true if this submesh covers the entire parent mesh
  20674. * @ignorenaming
  20675. */
  20676. readonly IsGlobal: boolean;
  20677. /**
  20678. * Returns the submesh BoudingInfo object
  20679. * @returns current bounding info (or mesh's one if the submesh is global)
  20680. */
  20681. getBoundingInfo(): BoundingInfo;
  20682. /**
  20683. * Sets the submesh BoundingInfo
  20684. * @param boundingInfo defines the new bounding info to use
  20685. * @returns the SubMesh
  20686. */
  20687. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20688. /**
  20689. * Returns the mesh of the current submesh
  20690. * @return the parent mesh
  20691. */
  20692. getMesh(): AbstractMesh;
  20693. /**
  20694. * Returns the rendering mesh of the submesh
  20695. * @returns the rendering mesh (could be different from parent mesh)
  20696. */
  20697. getRenderingMesh(): Mesh;
  20698. /**
  20699. * Returns the submesh material
  20700. * @returns null or the current material
  20701. */
  20702. getMaterial(): Nullable<Material>;
  20703. /**
  20704. * Sets a new updated BoundingInfo object to the submesh
  20705. * @param data defines an optional position array to use to determine the bounding info
  20706. * @returns the SubMesh
  20707. */
  20708. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20709. /** @hidden */
  20710. _checkCollision(collider: Collider): boolean;
  20711. /**
  20712. * Updates the submesh BoundingInfo
  20713. * @param world defines the world matrix to use to update the bounding info
  20714. * @returns the submesh
  20715. */
  20716. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20717. /**
  20718. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20719. * @param frustumPlanes defines the frustum planes
  20720. * @returns true if the submesh is intersecting with the frustum
  20721. */
  20722. isInFrustum(frustumPlanes: Plane[]): boolean;
  20723. /**
  20724. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20725. * @param frustumPlanes defines the frustum planes
  20726. * @returns true if the submesh is inside the frustum
  20727. */
  20728. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20729. /**
  20730. * Renders the submesh
  20731. * @param enableAlphaMode defines if alpha needs to be used
  20732. * @returns the submesh
  20733. */
  20734. render(enableAlphaMode: boolean): SubMesh;
  20735. /**
  20736. * @hidden
  20737. */
  20738. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20739. /**
  20740. * Checks if the submesh intersects with a ray
  20741. * @param ray defines the ray to test
  20742. * @returns true is the passed ray intersects the submesh bounding box
  20743. */
  20744. canIntersects(ray: Ray): boolean;
  20745. /**
  20746. * Intersects current submesh with a ray
  20747. * @param ray defines the ray to test
  20748. * @param positions defines mesh's positions array
  20749. * @param indices defines mesh's indices array
  20750. * @param fastCheck defines if only bounding info should be used
  20751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20752. * @returns intersection info or null if no intersection
  20753. */
  20754. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20755. /** @hidden */
  20756. private _intersectLines;
  20757. /** @hidden */
  20758. private _intersectUnIndexedLines;
  20759. /** @hidden */
  20760. private _intersectTriangles;
  20761. /** @hidden */
  20762. private _intersectUnIndexedTriangles;
  20763. /** @hidden */
  20764. _rebuild(): void;
  20765. /**
  20766. * Creates a new submesh from the passed mesh
  20767. * @param newMesh defines the new hosting mesh
  20768. * @param newRenderingMesh defines an optional rendering mesh
  20769. * @returns the new submesh
  20770. */
  20771. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20772. /**
  20773. * Release associated resources
  20774. */
  20775. dispose(): void;
  20776. /**
  20777. * Gets the class name
  20778. * @returns the string "SubMesh".
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Creates a new submesh from indices data
  20783. * @param materialIndex the index of the main mesh material
  20784. * @param startIndex the index where to start the copy in the mesh indices array
  20785. * @param indexCount the number of indices to copy then from the startIndex
  20786. * @param mesh the main mesh to create the submesh from
  20787. * @param renderingMesh the optional rendering mesh
  20788. * @returns a new submesh
  20789. */
  20790. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20791. }
  20792. }
  20793. declare module BABYLON {
  20794. /**
  20795. * Class used to represent data loading progression
  20796. */
  20797. export class SceneLoaderFlags {
  20798. private static _ForceFullSceneLoadingForIncremental;
  20799. private static _ShowLoadingScreen;
  20800. private static _CleanBoneMatrixWeights;
  20801. private static _loggingLevel;
  20802. /**
  20803. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20804. */
  20805. static ForceFullSceneLoadingForIncremental: boolean;
  20806. /**
  20807. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20808. */
  20809. static ShowLoadingScreen: boolean;
  20810. /**
  20811. * Defines the current logging level (while loading the scene)
  20812. * @ignorenaming
  20813. */
  20814. static loggingLevel: number;
  20815. /**
  20816. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20817. */
  20818. static CleanBoneMatrixWeights: boolean;
  20819. }
  20820. }
  20821. declare module BABYLON {
  20822. /**
  20823. * Class used to store geometry data (vertex buffers + index buffer)
  20824. */
  20825. export class Geometry implements IGetSetVerticesData {
  20826. /**
  20827. * Gets or sets the ID of the geometry
  20828. */
  20829. id: string;
  20830. /**
  20831. * Gets or sets the unique ID of the geometry
  20832. */
  20833. uniqueId: number;
  20834. /**
  20835. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20836. */
  20837. delayLoadState: number;
  20838. /**
  20839. * Gets the file containing the data to load when running in delay load state
  20840. */
  20841. delayLoadingFile: Nullable<string>;
  20842. /**
  20843. * Callback called when the geometry is updated
  20844. */
  20845. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20846. private _scene;
  20847. private _engine;
  20848. private _meshes;
  20849. private _totalVertices;
  20850. /** @hidden */
  20851. _indices: IndicesArray;
  20852. /** @hidden */
  20853. _vertexBuffers: {
  20854. [key: string]: VertexBuffer;
  20855. };
  20856. private _isDisposed;
  20857. private _extend;
  20858. private _boundingBias;
  20859. /** @hidden */
  20860. _delayInfo: Array<string>;
  20861. private _indexBuffer;
  20862. private _indexBufferIsUpdatable;
  20863. /** @hidden */
  20864. _boundingInfo: Nullable<BoundingInfo>;
  20865. /** @hidden */
  20866. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20867. /** @hidden */
  20868. _softwareSkinningFrameId: number;
  20869. private _vertexArrayObjects;
  20870. private _updatable;
  20871. /** @hidden */
  20872. _positions: Nullable<Vector3[]>;
  20873. /**
  20874. * 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
  20875. */
  20876. /**
  20877. * 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
  20878. */
  20879. boundingBias: Vector2;
  20880. /**
  20881. * Static function used to attach a new empty geometry to a mesh
  20882. * @param mesh defines the mesh to attach the geometry to
  20883. * @returns the new Geometry
  20884. */
  20885. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20886. /**
  20887. * Creates a new geometry
  20888. * @param id defines the unique ID
  20889. * @param scene defines the hosting scene
  20890. * @param vertexData defines the VertexData used to get geometry data
  20891. * @param updatable defines if geometry must be updatable (false by default)
  20892. * @param mesh defines the mesh that will be associated with the geometry
  20893. */
  20894. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20895. /**
  20896. * Gets the current extend of the geometry
  20897. */
  20898. readonly extend: {
  20899. minimum: Vector3;
  20900. maximum: Vector3;
  20901. };
  20902. /**
  20903. * Gets the hosting scene
  20904. * @returns the hosting Scene
  20905. */
  20906. getScene(): Scene;
  20907. /**
  20908. * Gets the hosting engine
  20909. * @returns the hosting Engine
  20910. */
  20911. getEngine(): Engine;
  20912. /**
  20913. * Defines if the geometry is ready to use
  20914. * @returns true if the geometry is ready to be used
  20915. */
  20916. isReady(): boolean;
  20917. /**
  20918. * Gets a value indicating that the geometry should not be serialized
  20919. */
  20920. readonly doNotSerialize: boolean;
  20921. /** @hidden */
  20922. _rebuild(): void;
  20923. /**
  20924. * Affects all geometry data in one call
  20925. * @param vertexData defines the geometry data
  20926. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20927. */
  20928. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20929. /**
  20930. * Set specific vertex data
  20931. * @param kind defines the data kind (Position, normal, etc...)
  20932. * @param data defines the vertex data to use
  20933. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20934. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20935. */
  20936. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20937. /**
  20938. * Removes a specific vertex data
  20939. * @param kind defines the data kind (Position, normal, etc...)
  20940. */
  20941. removeVerticesData(kind: string): void;
  20942. /**
  20943. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20944. * @param buffer defines the vertex buffer to use
  20945. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20946. */
  20947. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20948. /**
  20949. * Update a specific vertex buffer
  20950. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20951. * It will do nothing if the buffer is not updatable
  20952. * @param kind defines the data kind (Position, normal, etc...)
  20953. * @param data defines the data to use
  20954. * @param offset defines the offset in the target buffer where to store the data
  20955. * @param useBytes set to true if the offset is in bytes
  20956. */
  20957. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20958. /**
  20959. * Update a specific vertex buffer
  20960. * This function will create a new buffer if the current one is not updatable
  20961. * @param kind defines the data kind (Position, normal, etc...)
  20962. * @param data defines the data to use
  20963. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20964. */
  20965. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20966. private _updateBoundingInfo;
  20967. /** @hidden */
  20968. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20969. /**
  20970. * Gets total number of vertices
  20971. * @returns the total number of vertices
  20972. */
  20973. getTotalVertices(): number;
  20974. /**
  20975. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20976. * @param kind defines the data kind (Position, normal, etc...)
  20977. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20978. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20979. * @returns a float array containing vertex data
  20980. */
  20981. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20982. /**
  20983. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20984. * @param kind defines the data kind (Position, normal, etc...)
  20985. * @returns true if the vertex buffer with the specified kind is updatable
  20986. */
  20987. isVertexBufferUpdatable(kind: string): boolean;
  20988. /**
  20989. * Gets a specific vertex buffer
  20990. * @param kind defines the data kind (Position, normal, etc...)
  20991. * @returns a VertexBuffer
  20992. */
  20993. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20994. /**
  20995. * Returns all vertex buffers
  20996. * @return an object holding all vertex buffers indexed by kind
  20997. */
  20998. getVertexBuffers(): Nullable<{
  20999. [key: string]: VertexBuffer;
  21000. }>;
  21001. /**
  21002. * Gets a boolean indicating if specific vertex buffer is present
  21003. * @param kind defines the data kind (Position, normal, etc...)
  21004. * @returns true if data is present
  21005. */
  21006. isVerticesDataPresent(kind: string): boolean;
  21007. /**
  21008. * Gets a list of all attached data kinds (Position, normal, etc...)
  21009. * @returns a list of string containing all kinds
  21010. */
  21011. getVerticesDataKinds(): string[];
  21012. /**
  21013. * Update index buffer
  21014. * @param indices defines the indices to store in the index buffer
  21015. * @param offset defines the offset in the target buffer where to store the data
  21016. * @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)
  21017. */
  21018. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21019. /**
  21020. * Creates a new index buffer
  21021. * @param indices defines the indices to store in the index buffer
  21022. * @param totalVertices defines the total number of vertices (could be null)
  21023. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21024. */
  21025. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21026. /**
  21027. * Return the total number of indices
  21028. * @returns the total number of indices
  21029. */
  21030. getTotalIndices(): number;
  21031. /**
  21032. * Gets the index buffer array
  21033. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21034. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21035. * @returns the index buffer array
  21036. */
  21037. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21038. /**
  21039. * Gets the index buffer
  21040. * @return the index buffer
  21041. */
  21042. getIndexBuffer(): Nullable<DataBuffer>;
  21043. /** @hidden */
  21044. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21045. /**
  21046. * Release the associated resources for a specific mesh
  21047. * @param mesh defines the source mesh
  21048. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21049. */
  21050. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21051. /**
  21052. * Apply current geometry to a given mesh
  21053. * @param mesh defines the mesh to apply geometry to
  21054. */
  21055. applyToMesh(mesh: Mesh): void;
  21056. private _updateExtend;
  21057. private _applyToMesh;
  21058. private notifyUpdate;
  21059. /**
  21060. * Load the geometry if it was flagged as delay loaded
  21061. * @param scene defines the hosting scene
  21062. * @param onLoaded defines a callback called when the geometry is loaded
  21063. */
  21064. load(scene: Scene, onLoaded?: () => void): void;
  21065. private _queueLoad;
  21066. /**
  21067. * Invert the geometry to move from a right handed system to a left handed one.
  21068. */
  21069. toLeftHanded(): void;
  21070. /** @hidden */
  21071. _resetPointsArrayCache(): void;
  21072. /** @hidden */
  21073. _generatePointsArray(): boolean;
  21074. /**
  21075. * Gets a value indicating if the geometry is disposed
  21076. * @returns true if the geometry was disposed
  21077. */
  21078. isDisposed(): boolean;
  21079. private _disposeVertexArrayObjects;
  21080. /**
  21081. * Free all associated resources
  21082. */
  21083. dispose(): void;
  21084. /**
  21085. * Clone the current geometry into a new geometry
  21086. * @param id defines the unique ID of the new geometry
  21087. * @returns a new geometry object
  21088. */
  21089. copy(id: string): Geometry;
  21090. /**
  21091. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21092. * @return a JSON representation of the current geometry data (without the vertices data)
  21093. */
  21094. serialize(): any;
  21095. private toNumberArray;
  21096. /**
  21097. * Serialize all vertices data into a JSON oject
  21098. * @returns a JSON representation of the current geometry data
  21099. */
  21100. serializeVerticeData(): any;
  21101. /**
  21102. * Extracts a clone of a mesh geometry
  21103. * @param mesh defines the source mesh
  21104. * @param id defines the unique ID of the new geometry object
  21105. * @returns the new geometry object
  21106. */
  21107. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21108. /**
  21109. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21110. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21111. * Be aware Math.random() could cause collisions, but:
  21112. * "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"
  21113. * @returns a string containing a new GUID
  21114. */
  21115. static RandomId(): string;
  21116. /** @hidden */
  21117. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21118. private static _CleanMatricesWeights;
  21119. /**
  21120. * Create a new geometry from persisted data (Using .babylon file format)
  21121. * @param parsedVertexData defines the persisted data
  21122. * @param scene defines the hosting scene
  21123. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21124. * @returns the new geometry object
  21125. */
  21126. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21127. }
  21128. }
  21129. declare module BABYLON {
  21130. /**
  21131. * Define an interface for all classes that will get and set the data on vertices
  21132. */
  21133. export interface IGetSetVerticesData {
  21134. /**
  21135. * Gets a boolean indicating if specific vertex data is present
  21136. * @param kind defines the vertex data kind to use
  21137. * @returns true is data kind is present
  21138. */
  21139. isVerticesDataPresent(kind: string): boolean;
  21140. /**
  21141. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21142. * @param kind defines the data kind (Position, normal, etc...)
  21143. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21144. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21145. * @returns a float array containing vertex data
  21146. */
  21147. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21148. /**
  21149. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21150. * @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.
  21151. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21152. * @returns the indices array or an empty array if the mesh has no geometry
  21153. */
  21154. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21155. /**
  21156. * Set specific vertex data
  21157. * @param kind defines the data kind (Position, normal, etc...)
  21158. * @param data defines the vertex data to use
  21159. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21160. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21161. */
  21162. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21163. /**
  21164. * Update a specific associated vertex buffer
  21165. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21166. * - VertexBuffer.PositionKind
  21167. * - VertexBuffer.UVKind
  21168. * - VertexBuffer.UV2Kind
  21169. * - VertexBuffer.UV3Kind
  21170. * - VertexBuffer.UV4Kind
  21171. * - VertexBuffer.UV5Kind
  21172. * - VertexBuffer.UV6Kind
  21173. * - VertexBuffer.ColorKind
  21174. * - VertexBuffer.MatricesIndicesKind
  21175. * - VertexBuffer.MatricesIndicesExtraKind
  21176. * - VertexBuffer.MatricesWeightsKind
  21177. * - VertexBuffer.MatricesWeightsExtraKind
  21178. * @param data defines the data source
  21179. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21180. * @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)
  21181. */
  21182. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21183. /**
  21184. * Creates a new index buffer
  21185. * @param indices defines the indices to store in the index buffer
  21186. * @param totalVertices defines the total number of vertices (could be null)
  21187. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21188. */
  21189. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21190. }
  21191. /**
  21192. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21193. */
  21194. export class VertexData {
  21195. /**
  21196. * Mesh side orientation : usually the external or front surface
  21197. */
  21198. static readonly FRONTSIDE: number;
  21199. /**
  21200. * Mesh side orientation : usually the internal or back surface
  21201. */
  21202. static readonly BACKSIDE: number;
  21203. /**
  21204. * Mesh side orientation : both internal and external or front and back surfaces
  21205. */
  21206. static readonly DOUBLESIDE: number;
  21207. /**
  21208. * Mesh side orientation : by default, `FRONTSIDE`
  21209. */
  21210. static readonly DEFAULTSIDE: number;
  21211. /**
  21212. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21213. */
  21214. positions: Nullable<FloatArray>;
  21215. /**
  21216. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21217. */
  21218. normals: Nullable<FloatArray>;
  21219. /**
  21220. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21221. */
  21222. tangents: Nullable<FloatArray>;
  21223. /**
  21224. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21225. */
  21226. uvs: Nullable<FloatArray>;
  21227. /**
  21228. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21229. */
  21230. uvs2: Nullable<FloatArray>;
  21231. /**
  21232. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21233. */
  21234. uvs3: Nullable<FloatArray>;
  21235. /**
  21236. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21237. */
  21238. uvs4: Nullable<FloatArray>;
  21239. /**
  21240. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21241. */
  21242. uvs5: Nullable<FloatArray>;
  21243. /**
  21244. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21245. */
  21246. uvs6: Nullable<FloatArray>;
  21247. /**
  21248. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21249. */
  21250. colors: Nullable<FloatArray>;
  21251. /**
  21252. * 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).
  21253. */
  21254. matricesIndices: Nullable<FloatArray>;
  21255. /**
  21256. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21257. */
  21258. matricesWeights: Nullable<FloatArray>;
  21259. /**
  21260. * An array extending the number of possible indices
  21261. */
  21262. matricesIndicesExtra: Nullable<FloatArray>;
  21263. /**
  21264. * An array extending the number of possible weights when the number of indices is extended
  21265. */
  21266. matricesWeightsExtra: Nullable<FloatArray>;
  21267. /**
  21268. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21269. */
  21270. indices: Nullable<IndicesArray>;
  21271. /**
  21272. * Uses the passed data array to set the set the values for the specified kind of data
  21273. * @param data a linear array of floating numbers
  21274. * @param kind the type of data that is being set, eg positions, colors etc
  21275. */
  21276. set(data: FloatArray, kind: string): void;
  21277. /**
  21278. * Associates the vertexData to the passed Mesh.
  21279. * Sets it as updatable or not (default `false`)
  21280. * @param mesh the mesh the vertexData is applied to
  21281. * @param updatable when used and having the value true allows new data to update the vertexData
  21282. * @returns the VertexData
  21283. */
  21284. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21285. /**
  21286. * Associates the vertexData to the passed Geometry.
  21287. * Sets it as updatable or not (default `false`)
  21288. * @param geometry the geometry the vertexData is applied to
  21289. * @param updatable when used and having the value true allows new data to update the vertexData
  21290. * @returns VertexData
  21291. */
  21292. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21293. /**
  21294. * Updates the associated mesh
  21295. * @param mesh the mesh to be updated
  21296. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21297. * @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
  21298. * @returns VertexData
  21299. */
  21300. updateMesh(mesh: Mesh): VertexData;
  21301. /**
  21302. * Updates the associated geometry
  21303. * @param geometry the geometry to be updated
  21304. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21305. * @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
  21306. * @returns VertexData.
  21307. */
  21308. updateGeometry(geometry: Geometry): VertexData;
  21309. private _applyTo;
  21310. private _update;
  21311. /**
  21312. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21313. * @param matrix the transforming matrix
  21314. * @returns the VertexData
  21315. */
  21316. transform(matrix: Matrix): VertexData;
  21317. /**
  21318. * Merges the passed VertexData into the current one
  21319. * @param other the VertexData to be merged into the current one
  21320. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21321. * @returns the modified VertexData
  21322. */
  21323. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21324. private _mergeElement;
  21325. private _validate;
  21326. /**
  21327. * Serializes the VertexData
  21328. * @returns a serialized object
  21329. */
  21330. serialize(): any;
  21331. /**
  21332. * Extracts the vertexData from a mesh
  21333. * @param mesh the mesh from which to extract the VertexData
  21334. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21335. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21336. * @returns the object VertexData associated to the passed mesh
  21337. */
  21338. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21339. /**
  21340. * Extracts the vertexData from the geometry
  21341. * @param geometry the geometry from which to extract the VertexData
  21342. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21343. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21344. * @returns the object VertexData associated to the passed mesh
  21345. */
  21346. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21347. private static _ExtractFrom;
  21348. /**
  21349. * Creates the VertexData for a Ribbon
  21350. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21351. * * pathArray array of paths, each of which an array of successive Vector3
  21352. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21353. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21354. * * 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
  21355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21356. * * 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)
  21357. * * 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)
  21358. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21359. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21360. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21361. * @returns the VertexData of the ribbon
  21362. */
  21363. static CreateRibbon(options: {
  21364. pathArray: Vector3[][];
  21365. closeArray?: boolean;
  21366. closePath?: boolean;
  21367. offset?: number;
  21368. sideOrientation?: number;
  21369. frontUVs?: Vector4;
  21370. backUVs?: Vector4;
  21371. invertUV?: boolean;
  21372. uvs?: Vector2[];
  21373. colors?: Color4[];
  21374. }): VertexData;
  21375. /**
  21376. * Creates the VertexData for a box
  21377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21378. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21379. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21380. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21381. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21382. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21383. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21385. * * 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)
  21386. * * 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)
  21387. * @returns the VertexData of the box
  21388. */
  21389. static CreateBox(options: {
  21390. size?: number;
  21391. width?: number;
  21392. height?: number;
  21393. depth?: number;
  21394. faceUV?: Vector4[];
  21395. faceColors?: Color4[];
  21396. sideOrientation?: number;
  21397. frontUVs?: Vector4;
  21398. backUVs?: Vector4;
  21399. }): VertexData;
  21400. /**
  21401. * Creates the VertexData for a tiled box
  21402. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21403. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21404. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21405. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21406. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21407. * @returns the VertexData of the box
  21408. */
  21409. static CreateTiledBox(options: {
  21410. pattern?: number;
  21411. width?: number;
  21412. height?: number;
  21413. depth?: number;
  21414. tileSize?: number;
  21415. tileWidth?: number;
  21416. tileHeight?: number;
  21417. alignHorizontal?: number;
  21418. alignVertical?: number;
  21419. faceUV?: Vector4[];
  21420. faceColors?: Color4[];
  21421. sideOrientation?: number;
  21422. }): VertexData;
  21423. /**
  21424. * Creates the VertexData for a tiled plane
  21425. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21426. * * pattern a limited pattern arrangement depending on the number
  21427. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21428. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21429. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21431. * * 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)
  21432. * * 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)
  21433. * @returns the VertexData of the tiled plane
  21434. */
  21435. static CreateTiledPlane(options: {
  21436. pattern?: number;
  21437. tileSize?: number;
  21438. tileWidth?: number;
  21439. tileHeight?: number;
  21440. size?: number;
  21441. width?: number;
  21442. height?: number;
  21443. alignHorizontal?: number;
  21444. alignVertical?: number;
  21445. sideOrientation?: number;
  21446. frontUVs?: Vector4;
  21447. backUVs?: Vector4;
  21448. }): VertexData;
  21449. /**
  21450. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21451. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21452. * * segments sets the number of horizontal strips optional, default 32
  21453. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21454. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21455. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21456. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21457. * * 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
  21458. * * 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
  21459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21460. * * 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)
  21461. * * 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)
  21462. * @returns the VertexData of the ellipsoid
  21463. */
  21464. static CreateSphere(options: {
  21465. segments?: number;
  21466. diameter?: number;
  21467. diameterX?: number;
  21468. diameterY?: number;
  21469. diameterZ?: number;
  21470. arc?: number;
  21471. slice?: number;
  21472. sideOrientation?: number;
  21473. frontUVs?: Vector4;
  21474. backUVs?: Vector4;
  21475. }): VertexData;
  21476. /**
  21477. * Creates the VertexData for a cylinder, cone or prism
  21478. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21479. * * height sets the height (y direction) of the cylinder, optional, default 2
  21480. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21481. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21482. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21483. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21484. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21485. * * 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
  21486. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21487. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21488. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21489. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21491. * * 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)
  21492. * * 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)
  21493. * @returns the VertexData of the cylinder, cone or prism
  21494. */
  21495. static CreateCylinder(options: {
  21496. height?: number;
  21497. diameterTop?: number;
  21498. diameterBottom?: number;
  21499. diameter?: number;
  21500. tessellation?: number;
  21501. subdivisions?: number;
  21502. arc?: number;
  21503. faceColors?: Color4[];
  21504. faceUV?: Vector4[];
  21505. hasRings?: boolean;
  21506. enclose?: boolean;
  21507. sideOrientation?: number;
  21508. frontUVs?: Vector4;
  21509. backUVs?: Vector4;
  21510. }): VertexData;
  21511. /**
  21512. * Creates the VertexData for a torus
  21513. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21514. * * diameter the diameter of the torus, optional default 1
  21515. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21516. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21518. * * 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)
  21519. * * 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)
  21520. * @returns the VertexData of the torus
  21521. */
  21522. static CreateTorus(options: {
  21523. diameter?: number;
  21524. thickness?: number;
  21525. tessellation?: number;
  21526. sideOrientation?: number;
  21527. frontUVs?: Vector4;
  21528. backUVs?: Vector4;
  21529. }): VertexData;
  21530. /**
  21531. * Creates the VertexData of the LineSystem
  21532. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21533. * - lines an array of lines, each line being an array of successive Vector3
  21534. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21535. * @returns the VertexData of the LineSystem
  21536. */
  21537. static CreateLineSystem(options: {
  21538. lines: Vector3[][];
  21539. colors?: Nullable<Color4[][]>;
  21540. }): VertexData;
  21541. /**
  21542. * Create the VertexData for a DashedLines
  21543. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21544. * - points an array successive Vector3
  21545. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21546. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21547. * - dashNb the intended total number of dashes, optional, default 200
  21548. * @returns the VertexData for the DashedLines
  21549. */
  21550. static CreateDashedLines(options: {
  21551. points: Vector3[];
  21552. dashSize?: number;
  21553. gapSize?: number;
  21554. dashNb?: number;
  21555. }): VertexData;
  21556. /**
  21557. * Creates the VertexData for a Ground
  21558. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21559. * - width the width (x direction) of the ground, optional, default 1
  21560. * - height the height (z direction) of the ground, optional, default 1
  21561. * - subdivisions the number of subdivisions per side, optional, default 1
  21562. * @returns the VertexData of the Ground
  21563. */
  21564. static CreateGround(options: {
  21565. width?: number;
  21566. height?: number;
  21567. subdivisions?: number;
  21568. subdivisionsX?: number;
  21569. subdivisionsY?: number;
  21570. }): VertexData;
  21571. /**
  21572. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21573. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21574. * * xmin the ground minimum X coordinate, optional, default -1
  21575. * * zmin the ground minimum Z coordinate, optional, default -1
  21576. * * xmax the ground maximum X coordinate, optional, default 1
  21577. * * zmax the ground maximum Z coordinate, optional, default 1
  21578. * * 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}
  21579. * * 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}
  21580. * @returns the VertexData of the TiledGround
  21581. */
  21582. static CreateTiledGround(options: {
  21583. xmin: number;
  21584. zmin: number;
  21585. xmax: number;
  21586. zmax: number;
  21587. subdivisions?: {
  21588. w: number;
  21589. h: number;
  21590. };
  21591. precision?: {
  21592. w: number;
  21593. h: number;
  21594. };
  21595. }): VertexData;
  21596. /**
  21597. * Creates the VertexData of the Ground designed from a heightmap
  21598. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21599. * * width the width (x direction) of the ground
  21600. * * height the height (z direction) of the ground
  21601. * * subdivisions the number of subdivisions per side
  21602. * * minHeight the minimum altitude on the ground, optional, default 0
  21603. * * maxHeight the maximum altitude on the ground, optional default 1
  21604. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21605. * * buffer the array holding the image color data
  21606. * * bufferWidth the width of image
  21607. * * bufferHeight the height of image
  21608. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21609. * @returns the VertexData of the Ground designed from a heightmap
  21610. */
  21611. static CreateGroundFromHeightMap(options: {
  21612. width: number;
  21613. height: number;
  21614. subdivisions: number;
  21615. minHeight: number;
  21616. maxHeight: number;
  21617. colorFilter: Color3;
  21618. buffer: Uint8Array;
  21619. bufferWidth: number;
  21620. bufferHeight: number;
  21621. alphaFilter: number;
  21622. }): VertexData;
  21623. /**
  21624. * Creates the VertexData for a Plane
  21625. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21626. * * size sets the width and height of the plane to the value of size, optional default 1
  21627. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21628. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21629. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21630. * * 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)
  21631. * * 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)
  21632. * @returns the VertexData of the box
  21633. */
  21634. static CreatePlane(options: {
  21635. size?: number;
  21636. width?: number;
  21637. height?: number;
  21638. sideOrientation?: number;
  21639. frontUVs?: Vector4;
  21640. backUVs?: Vector4;
  21641. }): VertexData;
  21642. /**
  21643. * Creates the VertexData of the Disc or regular Polygon
  21644. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21645. * * radius the radius of the disc, optional default 0.5
  21646. * * tessellation the number of polygon sides, optional, default 64
  21647. * * 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
  21648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21649. * * 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)
  21650. * * 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)
  21651. * @returns the VertexData of the box
  21652. */
  21653. static CreateDisc(options: {
  21654. radius?: number;
  21655. tessellation?: number;
  21656. arc?: number;
  21657. sideOrientation?: number;
  21658. frontUVs?: Vector4;
  21659. backUVs?: Vector4;
  21660. }): VertexData;
  21661. /**
  21662. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21663. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21664. * @param polygon a mesh built from polygonTriangulation.build()
  21665. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21666. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21667. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21668. * @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)
  21669. * @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)
  21670. * @returns the VertexData of the Polygon
  21671. */
  21672. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21673. /**
  21674. * Creates the VertexData of the IcoSphere
  21675. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21676. * * radius the radius of the IcoSphere, optional default 1
  21677. * * radiusX allows stretching in the x direction, optional, default radius
  21678. * * radiusY allows stretching in the y direction, optional, default radius
  21679. * * radiusZ allows stretching in the z direction, optional, default radius
  21680. * * flat when true creates a flat shaded mesh, optional, default true
  21681. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21683. * * 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)
  21684. * * 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)
  21685. * @returns the VertexData of the IcoSphere
  21686. */
  21687. static CreateIcoSphere(options: {
  21688. radius?: number;
  21689. radiusX?: number;
  21690. radiusY?: number;
  21691. radiusZ?: number;
  21692. flat?: boolean;
  21693. subdivisions?: number;
  21694. sideOrientation?: number;
  21695. frontUVs?: Vector4;
  21696. backUVs?: Vector4;
  21697. }): VertexData;
  21698. /**
  21699. * Creates the VertexData for a Polyhedron
  21700. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21701. * * type provided types are:
  21702. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21703. * * 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)
  21704. * * size the size of the IcoSphere, optional default 1
  21705. * * sizeX allows stretching in the x direction, optional, default size
  21706. * * sizeY allows stretching in the y direction, optional, default size
  21707. * * sizeZ allows stretching in the z direction, optional, default size
  21708. * * 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
  21709. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21710. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21711. * * flat when true creates a flat shaded mesh, optional, default true
  21712. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 Polyhedron
  21717. */
  21718. static CreatePolyhedron(options: {
  21719. type?: number;
  21720. size?: number;
  21721. sizeX?: number;
  21722. sizeY?: number;
  21723. sizeZ?: number;
  21724. custom?: any;
  21725. faceUV?: Vector4[];
  21726. faceColors?: Color4[];
  21727. flat?: boolean;
  21728. sideOrientation?: number;
  21729. frontUVs?: Vector4;
  21730. backUVs?: Vector4;
  21731. }): VertexData;
  21732. /**
  21733. * Creates the VertexData for a TorusKnot
  21734. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21735. * * radius the radius of the torus knot, optional, default 2
  21736. * * tube the thickness of the tube, optional, default 0.5
  21737. * * radialSegments the number of sides on each tube segments, optional, default 32
  21738. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21739. * * p the number of windings around the z axis, optional, default 2
  21740. * * q the number of windings around the x axis, optional, default 3
  21741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21742. * * 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)
  21743. * * 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)
  21744. * @returns the VertexData of the Torus Knot
  21745. */
  21746. static CreateTorusKnot(options: {
  21747. radius?: number;
  21748. tube?: number;
  21749. radialSegments?: number;
  21750. tubularSegments?: number;
  21751. p?: number;
  21752. q?: number;
  21753. sideOrientation?: number;
  21754. frontUVs?: Vector4;
  21755. backUVs?: Vector4;
  21756. }): VertexData;
  21757. /**
  21758. * Compute normals for given positions and indices
  21759. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21760. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21761. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21762. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21763. * * facetNormals : optional array of facet normals (vector3)
  21764. * * facetPositions : optional array of facet positions (vector3)
  21765. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21766. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21767. * * bInfo : optional bounding info, required for facetPartitioning computation
  21768. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21769. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21770. * * useRightHandedSystem: optional boolean to for right handed system computation
  21771. * * depthSort : optional boolean to enable the facet depth sort computation
  21772. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21773. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21774. */
  21775. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21776. facetNormals?: any;
  21777. facetPositions?: any;
  21778. facetPartitioning?: any;
  21779. ratio?: number;
  21780. bInfo?: any;
  21781. bbSize?: Vector3;
  21782. subDiv?: any;
  21783. useRightHandedSystem?: boolean;
  21784. depthSort?: boolean;
  21785. distanceTo?: Vector3;
  21786. depthSortedFacets?: any;
  21787. }): void;
  21788. /** @hidden */
  21789. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21790. /**
  21791. * Applies VertexData created from the imported parameters to the geometry
  21792. * @param parsedVertexData the parsed data from an imported file
  21793. * @param geometry the geometry to apply the VertexData to
  21794. */
  21795. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21796. }
  21797. }
  21798. declare module BABYLON {
  21799. /**
  21800. * Defines a target to use with MorphTargetManager
  21801. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21802. */
  21803. export class MorphTarget implements IAnimatable {
  21804. /** defines the name of the target */
  21805. name: string;
  21806. /**
  21807. * Gets or sets the list of animations
  21808. */
  21809. animations: Animation[];
  21810. private _scene;
  21811. private _positions;
  21812. private _normals;
  21813. private _tangents;
  21814. private _uvs;
  21815. private _influence;
  21816. /**
  21817. * Observable raised when the influence changes
  21818. */
  21819. onInfluenceChanged: Observable<boolean>;
  21820. /** @hidden */
  21821. _onDataLayoutChanged: Observable<void>;
  21822. /**
  21823. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21824. */
  21825. influence: number;
  21826. /**
  21827. * Gets or sets the id of the morph Target
  21828. */
  21829. id: string;
  21830. private _animationPropertiesOverride;
  21831. /**
  21832. * Gets or sets the animation properties override
  21833. */
  21834. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21835. /**
  21836. * Creates a new MorphTarget
  21837. * @param name defines the name of the target
  21838. * @param influence defines the influence to use
  21839. * @param scene defines the scene the morphtarget belongs to
  21840. */
  21841. constructor(
  21842. /** defines the name of the target */
  21843. name: string, influence?: number, scene?: Nullable<Scene>);
  21844. /**
  21845. * Gets a boolean defining if the target contains position data
  21846. */
  21847. readonly hasPositions: boolean;
  21848. /**
  21849. * Gets a boolean defining if the target contains normal data
  21850. */
  21851. readonly hasNormals: boolean;
  21852. /**
  21853. * Gets a boolean defining if the target contains tangent data
  21854. */
  21855. readonly hasTangents: boolean;
  21856. /**
  21857. * Gets a boolean defining if the target contains texture coordinates data
  21858. */
  21859. readonly hasUVs: boolean;
  21860. /**
  21861. * Affects position data to this target
  21862. * @param data defines the position data to use
  21863. */
  21864. setPositions(data: Nullable<FloatArray>): void;
  21865. /**
  21866. * Gets the position data stored in this target
  21867. * @returns a FloatArray containing the position data (or null if not present)
  21868. */
  21869. getPositions(): Nullable<FloatArray>;
  21870. /**
  21871. * Affects normal data to this target
  21872. * @param data defines the normal data to use
  21873. */
  21874. setNormals(data: Nullable<FloatArray>): void;
  21875. /**
  21876. * Gets the normal data stored in this target
  21877. * @returns a FloatArray containing the normal data (or null if not present)
  21878. */
  21879. getNormals(): Nullable<FloatArray>;
  21880. /**
  21881. * Affects tangent data to this target
  21882. * @param data defines the tangent data to use
  21883. */
  21884. setTangents(data: Nullable<FloatArray>): void;
  21885. /**
  21886. * Gets the tangent data stored in this target
  21887. * @returns a FloatArray containing the tangent data (or null if not present)
  21888. */
  21889. getTangents(): Nullable<FloatArray>;
  21890. /**
  21891. * Affects texture coordinates data to this target
  21892. * @param data defines the texture coordinates data to use
  21893. */
  21894. setUVs(data: Nullable<FloatArray>): void;
  21895. /**
  21896. * Gets the texture coordinates data stored in this target
  21897. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21898. */
  21899. getUVs(): Nullable<FloatArray>;
  21900. /**
  21901. * Serializes the current target into a Serialization object
  21902. * @returns the serialized object
  21903. */
  21904. serialize(): any;
  21905. /**
  21906. * Returns the string "MorphTarget"
  21907. * @returns "MorphTarget"
  21908. */
  21909. getClassName(): string;
  21910. /**
  21911. * Creates a new target from serialized data
  21912. * @param serializationObject defines the serialized data to use
  21913. * @returns a new MorphTarget
  21914. */
  21915. static Parse(serializationObject: any): MorphTarget;
  21916. /**
  21917. * Creates a MorphTarget from mesh data
  21918. * @param mesh defines the source mesh
  21919. * @param name defines the name to use for the new target
  21920. * @param influence defines the influence to attach to the target
  21921. * @returns a new MorphTarget
  21922. */
  21923. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21924. }
  21925. }
  21926. declare module BABYLON {
  21927. /**
  21928. * This class is used to deform meshes using morphing between different targets
  21929. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21930. */
  21931. export class MorphTargetManager {
  21932. private _targets;
  21933. private _targetInfluenceChangedObservers;
  21934. private _targetDataLayoutChangedObservers;
  21935. private _activeTargets;
  21936. private _scene;
  21937. private _influences;
  21938. private _supportsNormals;
  21939. private _supportsTangents;
  21940. private _supportsUVs;
  21941. private _vertexCount;
  21942. private _uniqueId;
  21943. private _tempInfluences;
  21944. /**
  21945. * Gets or sets a boolean indicating if normals must be morphed
  21946. */
  21947. enableNormalMorphing: boolean;
  21948. /**
  21949. * Gets or sets a boolean indicating if tangents must be morphed
  21950. */
  21951. enableTangentMorphing: boolean;
  21952. /**
  21953. * Gets or sets a boolean indicating if UV must be morphed
  21954. */
  21955. enableUVMorphing: boolean;
  21956. /**
  21957. * Creates a new MorphTargetManager
  21958. * @param scene defines the current scene
  21959. */
  21960. constructor(scene?: Nullable<Scene>);
  21961. /**
  21962. * Gets the unique ID of this manager
  21963. */
  21964. readonly uniqueId: number;
  21965. /**
  21966. * Gets the number of vertices handled by this manager
  21967. */
  21968. readonly vertexCount: number;
  21969. /**
  21970. * Gets a boolean indicating if this manager supports morphing of normals
  21971. */
  21972. readonly supportsNormals: boolean;
  21973. /**
  21974. * Gets a boolean indicating if this manager supports morphing of tangents
  21975. */
  21976. readonly supportsTangents: boolean;
  21977. /**
  21978. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21979. */
  21980. readonly supportsUVs: boolean;
  21981. /**
  21982. * Gets the number of targets stored in this manager
  21983. */
  21984. readonly numTargets: number;
  21985. /**
  21986. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21987. */
  21988. readonly numInfluencers: number;
  21989. /**
  21990. * Gets the list of influences (one per target)
  21991. */
  21992. readonly influences: Float32Array;
  21993. /**
  21994. * Gets the active target at specified index. An active target is a target with an influence > 0
  21995. * @param index defines the index to check
  21996. * @returns the requested target
  21997. */
  21998. getActiveTarget(index: number): MorphTarget;
  21999. /**
  22000. * Gets the target at specified index
  22001. * @param index defines the index to check
  22002. * @returns the requested target
  22003. */
  22004. getTarget(index: number): MorphTarget;
  22005. /**
  22006. * Add a new target to this manager
  22007. * @param target defines the target to add
  22008. */
  22009. addTarget(target: MorphTarget): void;
  22010. /**
  22011. * Removes a target from the manager
  22012. * @param target defines the target to remove
  22013. */
  22014. removeTarget(target: MorphTarget): void;
  22015. /**
  22016. * Serializes the current manager into a Serialization object
  22017. * @returns the serialized object
  22018. */
  22019. serialize(): any;
  22020. private _syncActiveTargets;
  22021. /**
  22022. * Syncrhonize the targets with all the meshes using this morph target manager
  22023. */
  22024. synchronize(): void;
  22025. /**
  22026. * Creates a new MorphTargetManager from serialized data
  22027. * @param serializationObject defines the serialized data
  22028. * @param scene defines the hosting scene
  22029. * @returns the new MorphTargetManager
  22030. */
  22031. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22032. }
  22033. }
  22034. declare module BABYLON {
  22035. /**
  22036. * Class used to represent a specific level of detail of a mesh
  22037. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22038. */
  22039. export class MeshLODLevel {
  22040. /** Defines the distance where this level should start being displayed */
  22041. distance: number;
  22042. /** Defines the mesh to use to render this level */
  22043. mesh: Nullable<Mesh>;
  22044. /**
  22045. * Creates a new LOD level
  22046. * @param distance defines the distance where this level should star being displayed
  22047. * @param mesh defines the mesh to use to render this level
  22048. */
  22049. constructor(
  22050. /** Defines the distance where this level should start being displayed */
  22051. distance: number,
  22052. /** Defines the mesh to use to render this level */
  22053. mesh: Nullable<Mesh>);
  22054. }
  22055. }
  22056. declare module BABYLON {
  22057. /**
  22058. * Mesh representing the gorund
  22059. */
  22060. export class GroundMesh extends Mesh {
  22061. /** If octree should be generated */
  22062. generateOctree: boolean;
  22063. private _heightQuads;
  22064. /** @hidden */
  22065. _subdivisionsX: number;
  22066. /** @hidden */
  22067. _subdivisionsY: number;
  22068. /** @hidden */
  22069. _width: number;
  22070. /** @hidden */
  22071. _height: number;
  22072. /** @hidden */
  22073. _minX: number;
  22074. /** @hidden */
  22075. _maxX: number;
  22076. /** @hidden */
  22077. _minZ: number;
  22078. /** @hidden */
  22079. _maxZ: number;
  22080. constructor(name: string, scene: Scene);
  22081. /**
  22082. * "GroundMesh"
  22083. * @returns "GroundMesh"
  22084. */
  22085. getClassName(): string;
  22086. /**
  22087. * The minimum of x and y subdivisions
  22088. */
  22089. readonly subdivisions: number;
  22090. /**
  22091. * X subdivisions
  22092. */
  22093. readonly subdivisionsX: number;
  22094. /**
  22095. * Y subdivisions
  22096. */
  22097. readonly subdivisionsY: number;
  22098. /**
  22099. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22100. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22101. * @param chunksCount the number of subdivisions for x and y
  22102. * @param octreeBlocksSize (Default: 32)
  22103. */
  22104. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22105. /**
  22106. * Returns a height (y) value in the Worl system :
  22107. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22108. * @param x x coordinate
  22109. * @param z z coordinate
  22110. * @returns the ground y position if (x, z) are outside the ground surface.
  22111. */
  22112. getHeightAtCoordinates(x: number, z: number): number;
  22113. /**
  22114. * Returns a normalized vector (Vector3) orthogonal to the ground
  22115. * at the ground coordinates (x, z) expressed in the World system.
  22116. * @param x x coordinate
  22117. * @param z z coordinate
  22118. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22119. */
  22120. getNormalAtCoordinates(x: number, z: number): Vector3;
  22121. /**
  22122. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22123. * at the ground coordinates (x, z) expressed in the World system.
  22124. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22125. * @param x x coordinate
  22126. * @param z z coordinate
  22127. * @param ref vector to store the result
  22128. * @returns the GroundMesh.
  22129. */
  22130. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22131. /**
  22132. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22133. * if the ground has been updated.
  22134. * This can be used in the render loop.
  22135. * @returns the GroundMesh.
  22136. */
  22137. updateCoordinateHeights(): GroundMesh;
  22138. private _getFacetAt;
  22139. private _initHeightQuads;
  22140. private _computeHeightQuads;
  22141. /**
  22142. * Serializes this ground mesh
  22143. * @param serializationObject object to write serialization to
  22144. */
  22145. serialize(serializationObject: any): void;
  22146. /**
  22147. * Parses a serialized ground mesh
  22148. * @param parsedMesh the serialized mesh
  22149. * @param scene the scene to create the ground mesh in
  22150. * @returns the created ground mesh
  22151. */
  22152. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22153. }
  22154. }
  22155. declare module BABYLON {
  22156. /**
  22157. * Interface for Physics-Joint data
  22158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22159. */
  22160. export interface PhysicsJointData {
  22161. /**
  22162. * The main pivot of the joint
  22163. */
  22164. mainPivot?: Vector3;
  22165. /**
  22166. * The connected pivot of the joint
  22167. */
  22168. connectedPivot?: Vector3;
  22169. /**
  22170. * The main axis of the joint
  22171. */
  22172. mainAxis?: Vector3;
  22173. /**
  22174. * The connected axis of the joint
  22175. */
  22176. connectedAxis?: Vector3;
  22177. /**
  22178. * The collision of the joint
  22179. */
  22180. collision?: boolean;
  22181. /**
  22182. * Native Oimo/Cannon/Energy data
  22183. */
  22184. nativeParams?: any;
  22185. }
  22186. /**
  22187. * This is a holder class for the physics joint created by the physics plugin
  22188. * It holds a set of functions to control the underlying joint
  22189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22190. */
  22191. export class PhysicsJoint {
  22192. /**
  22193. * The type of the physics joint
  22194. */
  22195. type: number;
  22196. /**
  22197. * The data for the physics joint
  22198. */
  22199. jointData: PhysicsJointData;
  22200. private _physicsJoint;
  22201. protected _physicsPlugin: IPhysicsEnginePlugin;
  22202. /**
  22203. * Initializes the physics joint
  22204. * @param type The type of the physics joint
  22205. * @param jointData The data for the physics joint
  22206. */
  22207. constructor(
  22208. /**
  22209. * The type of the physics joint
  22210. */
  22211. type: number,
  22212. /**
  22213. * The data for the physics joint
  22214. */
  22215. jointData: PhysicsJointData);
  22216. /**
  22217. * Gets the physics joint
  22218. */
  22219. /**
  22220. * Sets the physics joint
  22221. */
  22222. physicsJoint: any;
  22223. /**
  22224. * Sets the physics plugin
  22225. */
  22226. physicsPlugin: IPhysicsEnginePlugin;
  22227. /**
  22228. * Execute a function that is physics-plugin specific.
  22229. * @param {Function} func the function that will be executed.
  22230. * It accepts two parameters: the physics world and the physics joint
  22231. */
  22232. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22233. /**
  22234. * Distance-Joint type
  22235. */
  22236. static DistanceJoint: number;
  22237. /**
  22238. * Hinge-Joint type
  22239. */
  22240. static HingeJoint: number;
  22241. /**
  22242. * Ball-and-Socket joint type
  22243. */
  22244. static BallAndSocketJoint: number;
  22245. /**
  22246. * Wheel-Joint type
  22247. */
  22248. static WheelJoint: number;
  22249. /**
  22250. * Slider-Joint type
  22251. */
  22252. static SliderJoint: number;
  22253. /**
  22254. * Prismatic-Joint type
  22255. */
  22256. static PrismaticJoint: number;
  22257. /**
  22258. * Universal-Joint type
  22259. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22260. */
  22261. static UniversalJoint: number;
  22262. /**
  22263. * Hinge-Joint 2 type
  22264. */
  22265. static Hinge2Joint: number;
  22266. /**
  22267. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22268. */
  22269. static PointToPointJoint: number;
  22270. /**
  22271. * Spring-Joint type
  22272. */
  22273. static SpringJoint: number;
  22274. /**
  22275. * Lock-Joint type
  22276. */
  22277. static LockJoint: number;
  22278. }
  22279. /**
  22280. * A class representing a physics distance joint
  22281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22282. */
  22283. export class DistanceJoint extends PhysicsJoint {
  22284. /**
  22285. *
  22286. * @param jointData The data for the Distance-Joint
  22287. */
  22288. constructor(jointData: DistanceJointData);
  22289. /**
  22290. * Update the predefined distance.
  22291. * @param maxDistance The maximum preferred distance
  22292. * @param minDistance The minimum preferred distance
  22293. */
  22294. updateDistance(maxDistance: number, minDistance?: number): void;
  22295. }
  22296. /**
  22297. * Represents a Motor-Enabled Joint
  22298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22299. */
  22300. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22301. /**
  22302. * Initializes the Motor-Enabled Joint
  22303. * @param type The type of the joint
  22304. * @param jointData The physica joint data for the joint
  22305. */
  22306. constructor(type: number, jointData: PhysicsJointData);
  22307. /**
  22308. * Set the motor values.
  22309. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22310. * @param force the force to apply
  22311. * @param maxForce max force for this motor.
  22312. */
  22313. setMotor(force?: number, maxForce?: number): void;
  22314. /**
  22315. * Set the motor's limits.
  22316. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22317. * @param upperLimit The upper limit of the motor
  22318. * @param lowerLimit The lower limit of the motor
  22319. */
  22320. setLimit(upperLimit: number, lowerLimit?: number): void;
  22321. }
  22322. /**
  22323. * This class represents a single physics Hinge-Joint
  22324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22325. */
  22326. export class HingeJoint extends MotorEnabledJoint {
  22327. /**
  22328. * Initializes the Hinge-Joint
  22329. * @param jointData The joint data for the Hinge-Joint
  22330. */
  22331. constructor(jointData: PhysicsJointData);
  22332. /**
  22333. * Set the motor values.
  22334. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22335. * @param {number} force the force to apply
  22336. * @param {number} maxForce max force for this motor.
  22337. */
  22338. setMotor(force?: number, maxForce?: number): void;
  22339. /**
  22340. * Set the motor's limits.
  22341. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22342. * @param upperLimit The upper limit of the motor
  22343. * @param lowerLimit The lower limit of the motor
  22344. */
  22345. setLimit(upperLimit: number, lowerLimit?: number): void;
  22346. }
  22347. /**
  22348. * This class represents a dual hinge physics joint (same as wheel joint)
  22349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22350. */
  22351. export class Hinge2Joint extends MotorEnabledJoint {
  22352. /**
  22353. * Initializes the Hinge2-Joint
  22354. * @param jointData The joint data for the Hinge2-Joint
  22355. */
  22356. constructor(jointData: PhysicsJointData);
  22357. /**
  22358. * Set the motor values.
  22359. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22360. * @param {number} targetSpeed the speed the motor is to reach
  22361. * @param {number} maxForce max force for this motor.
  22362. * @param {motorIndex} the motor's index, 0 or 1.
  22363. */
  22364. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22365. /**
  22366. * Set the motor limits.
  22367. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22368. * @param {number} upperLimit the upper limit
  22369. * @param {number} lowerLimit lower limit
  22370. * @param {motorIndex} the motor's index, 0 or 1.
  22371. */
  22372. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22373. }
  22374. /**
  22375. * Interface for a motor enabled joint
  22376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22377. */
  22378. export interface IMotorEnabledJoint {
  22379. /**
  22380. * Physics joint
  22381. */
  22382. physicsJoint: any;
  22383. /**
  22384. * Sets the motor of the motor-enabled joint
  22385. * @param force The force of the motor
  22386. * @param maxForce The maximum force of the motor
  22387. * @param motorIndex The index of the motor
  22388. */
  22389. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22390. /**
  22391. * Sets the limit of the motor
  22392. * @param upperLimit The upper limit of the motor
  22393. * @param lowerLimit The lower limit of the motor
  22394. * @param motorIndex The index of the motor
  22395. */
  22396. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22397. }
  22398. /**
  22399. * Joint data for a Distance-Joint
  22400. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22401. */
  22402. export interface DistanceJointData extends PhysicsJointData {
  22403. /**
  22404. * Max distance the 2 joint objects can be apart
  22405. */
  22406. maxDistance: number;
  22407. }
  22408. /**
  22409. * Joint data from a spring joint
  22410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22411. */
  22412. export interface SpringJointData extends PhysicsJointData {
  22413. /**
  22414. * Length of the spring
  22415. */
  22416. length: number;
  22417. /**
  22418. * Stiffness of the spring
  22419. */
  22420. stiffness: number;
  22421. /**
  22422. * Damping of the spring
  22423. */
  22424. damping: number;
  22425. /** this callback will be called when applying the force to the impostors. */
  22426. forceApplicationCallback: () => void;
  22427. }
  22428. }
  22429. declare module BABYLON {
  22430. /**
  22431. * Holds the data for the raycast result
  22432. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22433. */
  22434. export class PhysicsRaycastResult {
  22435. private _hasHit;
  22436. private _hitDistance;
  22437. private _hitNormalWorld;
  22438. private _hitPointWorld;
  22439. private _rayFromWorld;
  22440. private _rayToWorld;
  22441. /**
  22442. * Gets if there was a hit
  22443. */
  22444. readonly hasHit: boolean;
  22445. /**
  22446. * Gets the distance from the hit
  22447. */
  22448. readonly hitDistance: number;
  22449. /**
  22450. * Gets the hit normal/direction in the world
  22451. */
  22452. readonly hitNormalWorld: Vector3;
  22453. /**
  22454. * Gets the hit point in the world
  22455. */
  22456. readonly hitPointWorld: Vector3;
  22457. /**
  22458. * Gets the ray "start point" of the ray in the world
  22459. */
  22460. readonly rayFromWorld: Vector3;
  22461. /**
  22462. * Gets the ray "end point" of the ray in the world
  22463. */
  22464. readonly rayToWorld: Vector3;
  22465. /**
  22466. * Sets the hit data (normal & point in world space)
  22467. * @param hitNormalWorld defines the normal in world space
  22468. * @param hitPointWorld defines the point in world space
  22469. */
  22470. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22471. /**
  22472. * Sets the distance from the start point to the hit point
  22473. * @param distance
  22474. */
  22475. setHitDistance(distance: number): void;
  22476. /**
  22477. * Calculates the distance manually
  22478. */
  22479. calculateHitDistance(): void;
  22480. /**
  22481. * Resets all the values to default
  22482. * @param from The from point on world space
  22483. * @param to The to point on world space
  22484. */
  22485. reset(from?: Vector3, to?: Vector3): void;
  22486. }
  22487. /**
  22488. * Interface for the size containing width and height
  22489. */
  22490. interface IXYZ {
  22491. /**
  22492. * X
  22493. */
  22494. x: number;
  22495. /**
  22496. * Y
  22497. */
  22498. y: number;
  22499. /**
  22500. * Z
  22501. */
  22502. z: number;
  22503. }
  22504. }
  22505. declare module BABYLON {
  22506. /**
  22507. * Interface used to describe a physics joint
  22508. */
  22509. export interface PhysicsImpostorJoint {
  22510. /** Defines the main impostor to which the joint is linked */
  22511. mainImpostor: PhysicsImpostor;
  22512. /** Defines the impostor that is connected to the main impostor using this joint */
  22513. connectedImpostor: PhysicsImpostor;
  22514. /** Defines the joint itself */
  22515. joint: PhysicsJoint;
  22516. }
  22517. /** @hidden */
  22518. export interface IPhysicsEnginePlugin {
  22519. world: any;
  22520. name: string;
  22521. setGravity(gravity: Vector3): void;
  22522. setTimeStep(timeStep: number): void;
  22523. getTimeStep(): number;
  22524. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22525. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22526. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22527. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22528. removePhysicsBody(impostor: PhysicsImpostor): void;
  22529. generateJoint(joint: PhysicsImpostorJoint): void;
  22530. removeJoint(joint: PhysicsImpostorJoint): void;
  22531. isSupported(): boolean;
  22532. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22533. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22534. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22535. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22536. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22537. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22538. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22539. getBodyMass(impostor: PhysicsImpostor): number;
  22540. getBodyFriction(impostor: PhysicsImpostor): number;
  22541. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22542. getBodyRestitution(impostor: PhysicsImpostor): number;
  22543. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22544. getBodyPressure?(impostor: PhysicsImpostor): number;
  22545. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22546. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22547. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22548. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22549. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22550. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22551. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22552. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22553. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22554. sleepBody(impostor: PhysicsImpostor): void;
  22555. wakeUpBody(impostor: PhysicsImpostor): void;
  22556. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22558. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22560. getRadius(impostor: PhysicsImpostor): number;
  22561. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22562. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22563. dispose(): void;
  22564. }
  22565. /**
  22566. * Interface used to define a physics engine
  22567. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22568. */
  22569. export interface IPhysicsEngine {
  22570. /**
  22571. * Gets the gravity vector used by the simulation
  22572. */
  22573. gravity: Vector3;
  22574. /**
  22575. * Sets the gravity vector used by the simulation
  22576. * @param gravity defines the gravity vector to use
  22577. */
  22578. setGravity(gravity: Vector3): void;
  22579. /**
  22580. * Set the time step of the physics engine.
  22581. * Default is 1/60.
  22582. * To slow it down, enter 1/600 for example.
  22583. * To speed it up, 1/30
  22584. * @param newTimeStep the new timestep to apply to this world.
  22585. */
  22586. setTimeStep(newTimeStep: number): void;
  22587. /**
  22588. * Get the time step of the physics engine.
  22589. * @returns the current time step
  22590. */
  22591. getTimeStep(): number;
  22592. /**
  22593. * Release all resources
  22594. */
  22595. dispose(): void;
  22596. /**
  22597. * Gets the name of the current physics plugin
  22598. * @returns the name of the plugin
  22599. */
  22600. getPhysicsPluginName(): string;
  22601. /**
  22602. * Adding a new impostor for the impostor tracking.
  22603. * This will be done by the impostor itself.
  22604. * @param impostor the impostor to add
  22605. */
  22606. addImpostor(impostor: PhysicsImpostor): void;
  22607. /**
  22608. * Remove an impostor from the engine.
  22609. * This impostor and its mesh will not longer be updated by the physics engine.
  22610. * @param impostor the impostor to remove
  22611. */
  22612. removeImpostor(impostor: PhysicsImpostor): void;
  22613. /**
  22614. * Add a joint to the physics engine
  22615. * @param mainImpostor defines the main impostor to which the joint is added.
  22616. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22617. * @param joint defines the joint that will connect both impostors.
  22618. */
  22619. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22620. /**
  22621. * Removes a joint from the simulation
  22622. * @param mainImpostor defines the impostor used with the joint
  22623. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22624. * @param joint defines the joint to remove
  22625. */
  22626. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22627. /**
  22628. * Gets the current plugin used to run the simulation
  22629. * @returns current plugin
  22630. */
  22631. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22632. /**
  22633. * Gets the list of physic impostors
  22634. * @returns an array of PhysicsImpostor
  22635. */
  22636. getImpostors(): Array<PhysicsImpostor>;
  22637. /**
  22638. * Gets the impostor for a physics enabled object
  22639. * @param object defines the object impersonated by the impostor
  22640. * @returns the PhysicsImpostor or null if not found
  22641. */
  22642. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22643. /**
  22644. * Gets the impostor for a physics body object
  22645. * @param body defines physics body used by the impostor
  22646. * @returns the PhysicsImpostor or null if not found
  22647. */
  22648. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22649. /**
  22650. * Does a raycast in the physics world
  22651. * @param from when should the ray start?
  22652. * @param to when should the ray end?
  22653. * @returns PhysicsRaycastResult
  22654. */
  22655. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22656. /**
  22657. * Called by the scene. No need to call it.
  22658. * @param delta defines the timespam between frames
  22659. */
  22660. _step(delta: number): void;
  22661. }
  22662. }
  22663. declare module BABYLON {
  22664. /**
  22665. * The interface for the physics imposter parameters
  22666. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22667. */
  22668. export interface PhysicsImpostorParameters {
  22669. /**
  22670. * The mass of the physics imposter
  22671. */
  22672. mass: number;
  22673. /**
  22674. * The friction of the physics imposter
  22675. */
  22676. friction?: number;
  22677. /**
  22678. * The coefficient of restitution of the physics imposter
  22679. */
  22680. restitution?: number;
  22681. /**
  22682. * The native options of the physics imposter
  22683. */
  22684. nativeOptions?: any;
  22685. /**
  22686. * Specifies if the parent should be ignored
  22687. */
  22688. ignoreParent?: boolean;
  22689. /**
  22690. * Specifies if bi-directional transformations should be disabled
  22691. */
  22692. disableBidirectionalTransformation?: boolean;
  22693. /**
  22694. * The pressure inside the physics imposter, soft object only
  22695. */
  22696. pressure?: number;
  22697. /**
  22698. * The stiffness the physics imposter, soft object only
  22699. */
  22700. stiffness?: number;
  22701. /**
  22702. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22703. */
  22704. velocityIterations?: number;
  22705. /**
  22706. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22707. */
  22708. positionIterations?: number;
  22709. /**
  22710. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22711. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22712. * Add to fix multiple points
  22713. */
  22714. fixedPoints?: number;
  22715. /**
  22716. * The collision margin around a soft object
  22717. */
  22718. margin?: number;
  22719. /**
  22720. * The collision margin around a soft object
  22721. */
  22722. damping?: number;
  22723. /**
  22724. * The path for a rope based on an extrusion
  22725. */
  22726. path?: any;
  22727. /**
  22728. * The shape of an extrusion used for a rope based on an extrusion
  22729. */
  22730. shape?: any;
  22731. }
  22732. /**
  22733. * Interface for a physics-enabled object
  22734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22735. */
  22736. export interface IPhysicsEnabledObject {
  22737. /**
  22738. * The position of the physics-enabled object
  22739. */
  22740. position: Vector3;
  22741. /**
  22742. * The rotation of the physics-enabled object
  22743. */
  22744. rotationQuaternion: Nullable<Quaternion>;
  22745. /**
  22746. * The scale of the physics-enabled object
  22747. */
  22748. scaling: Vector3;
  22749. /**
  22750. * The rotation of the physics-enabled object
  22751. */
  22752. rotation?: Vector3;
  22753. /**
  22754. * The parent of the physics-enabled object
  22755. */
  22756. parent?: any;
  22757. /**
  22758. * The bounding info of the physics-enabled object
  22759. * @returns The bounding info of the physics-enabled object
  22760. */
  22761. getBoundingInfo(): BoundingInfo;
  22762. /**
  22763. * Computes the world matrix
  22764. * @param force Specifies if the world matrix should be computed by force
  22765. * @returns A world matrix
  22766. */
  22767. computeWorldMatrix(force: boolean): Matrix;
  22768. /**
  22769. * Gets the world matrix
  22770. * @returns A world matrix
  22771. */
  22772. getWorldMatrix?(): Matrix;
  22773. /**
  22774. * Gets the child meshes
  22775. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22776. * @returns An array of abstract meshes
  22777. */
  22778. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22779. /**
  22780. * Gets the vertex data
  22781. * @param kind The type of vertex data
  22782. * @returns A nullable array of numbers, or a float32 array
  22783. */
  22784. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22785. /**
  22786. * Gets the indices from the mesh
  22787. * @returns A nullable array of index arrays
  22788. */
  22789. getIndices?(): Nullable<IndicesArray>;
  22790. /**
  22791. * Gets the scene from the mesh
  22792. * @returns the indices array or null
  22793. */
  22794. getScene?(): Scene;
  22795. /**
  22796. * Gets the absolute position from the mesh
  22797. * @returns the absolute position
  22798. */
  22799. getAbsolutePosition(): Vector3;
  22800. /**
  22801. * Gets the absolute pivot point from the mesh
  22802. * @returns the absolute pivot point
  22803. */
  22804. getAbsolutePivotPoint(): Vector3;
  22805. /**
  22806. * Rotates the mesh
  22807. * @param axis The axis of rotation
  22808. * @param amount The amount of rotation
  22809. * @param space The space of the rotation
  22810. * @returns The rotation transform node
  22811. */
  22812. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22813. /**
  22814. * Translates the mesh
  22815. * @param axis The axis of translation
  22816. * @param distance The distance of translation
  22817. * @param space The space of the translation
  22818. * @returns The transform node
  22819. */
  22820. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22821. /**
  22822. * Sets the absolute position of the mesh
  22823. * @param absolutePosition The absolute position of the mesh
  22824. * @returns The transform node
  22825. */
  22826. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22827. /**
  22828. * Gets the class name of the mesh
  22829. * @returns The class name
  22830. */
  22831. getClassName(): string;
  22832. }
  22833. /**
  22834. * Represents a physics imposter
  22835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22836. */
  22837. export class PhysicsImpostor {
  22838. /**
  22839. * The physics-enabled object used as the physics imposter
  22840. */
  22841. object: IPhysicsEnabledObject;
  22842. /**
  22843. * The type of the physics imposter
  22844. */
  22845. type: number;
  22846. private _options;
  22847. private _scene?;
  22848. /**
  22849. * The default object size of the imposter
  22850. */
  22851. static DEFAULT_OBJECT_SIZE: Vector3;
  22852. /**
  22853. * The identity quaternion of the imposter
  22854. */
  22855. static IDENTITY_QUATERNION: Quaternion;
  22856. /** @hidden */
  22857. _pluginData: any;
  22858. private _physicsEngine;
  22859. private _physicsBody;
  22860. private _bodyUpdateRequired;
  22861. private _onBeforePhysicsStepCallbacks;
  22862. private _onAfterPhysicsStepCallbacks;
  22863. /** @hidden */
  22864. _onPhysicsCollideCallbacks: Array<{
  22865. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22866. otherImpostors: Array<PhysicsImpostor>;
  22867. }>;
  22868. private _deltaPosition;
  22869. private _deltaRotation;
  22870. private _deltaRotationConjugated;
  22871. /** @hidden */
  22872. _isFromLine: boolean;
  22873. private _parent;
  22874. private _isDisposed;
  22875. private static _tmpVecs;
  22876. private static _tmpQuat;
  22877. /**
  22878. * Specifies if the physics imposter is disposed
  22879. */
  22880. readonly isDisposed: boolean;
  22881. /**
  22882. * Gets the mass of the physics imposter
  22883. */
  22884. mass: number;
  22885. /**
  22886. * Gets the coefficient of friction
  22887. */
  22888. /**
  22889. * Sets the coefficient of friction
  22890. */
  22891. friction: number;
  22892. /**
  22893. * Gets the coefficient of restitution
  22894. */
  22895. /**
  22896. * Sets the coefficient of restitution
  22897. */
  22898. restitution: number;
  22899. /**
  22900. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22901. */
  22902. /**
  22903. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22904. */
  22905. pressure: number;
  22906. /**
  22907. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22908. */
  22909. /**
  22910. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22911. */
  22912. stiffness: number;
  22913. /**
  22914. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22915. */
  22916. /**
  22917. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22918. */
  22919. velocityIterations: number;
  22920. /**
  22921. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22922. */
  22923. /**
  22924. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22925. */
  22926. positionIterations: number;
  22927. /**
  22928. * The unique id of the physics imposter
  22929. * set by the physics engine when adding this impostor to the array
  22930. */
  22931. uniqueId: number;
  22932. /**
  22933. * @hidden
  22934. */
  22935. soft: boolean;
  22936. /**
  22937. * @hidden
  22938. */
  22939. segments: number;
  22940. private _joints;
  22941. /**
  22942. * Initializes the physics imposter
  22943. * @param object The physics-enabled object used as the physics imposter
  22944. * @param type The type of the physics imposter
  22945. * @param _options The options for the physics imposter
  22946. * @param _scene The Babylon scene
  22947. */
  22948. constructor(
  22949. /**
  22950. * The physics-enabled object used as the physics imposter
  22951. */
  22952. object: IPhysicsEnabledObject,
  22953. /**
  22954. * The type of the physics imposter
  22955. */
  22956. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22957. /**
  22958. * This function will completly initialize this impostor.
  22959. * It will create a new body - but only if this mesh has no parent.
  22960. * If it has, this impostor will not be used other than to define the impostor
  22961. * of the child mesh.
  22962. * @hidden
  22963. */
  22964. _init(): void;
  22965. private _getPhysicsParent;
  22966. /**
  22967. * Should a new body be generated.
  22968. * @returns boolean specifying if body initialization is required
  22969. */
  22970. isBodyInitRequired(): boolean;
  22971. /**
  22972. * Sets the updated scaling
  22973. * @param updated Specifies if the scaling is updated
  22974. */
  22975. setScalingUpdated(): void;
  22976. /**
  22977. * Force a regeneration of this or the parent's impostor's body.
  22978. * Use under cautious - This will remove all joints already implemented.
  22979. */
  22980. forceUpdate(): void;
  22981. /**
  22982. * Gets the body that holds this impostor. Either its own, or its parent.
  22983. */
  22984. /**
  22985. * Set the physics body. Used mainly by the physics engine/plugin
  22986. */
  22987. physicsBody: any;
  22988. /**
  22989. * Get the parent of the physics imposter
  22990. * @returns Physics imposter or null
  22991. */
  22992. /**
  22993. * Sets the parent of the physics imposter
  22994. */
  22995. parent: Nullable<PhysicsImpostor>;
  22996. /**
  22997. * Resets the update flags
  22998. */
  22999. resetUpdateFlags(): void;
  23000. /**
  23001. * Gets the object extend size
  23002. * @returns the object extend size
  23003. */
  23004. getObjectExtendSize(): Vector3;
  23005. /**
  23006. * Gets the object center
  23007. * @returns The object center
  23008. */
  23009. getObjectCenter(): Vector3;
  23010. /**
  23011. * Get a specific parametes from the options parameter
  23012. * @param paramName The object parameter name
  23013. * @returns The object parameter
  23014. */
  23015. getParam(paramName: string): any;
  23016. /**
  23017. * Sets a specific parameter in the options given to the physics plugin
  23018. * @param paramName The parameter name
  23019. * @param value The value of the parameter
  23020. */
  23021. setParam(paramName: string, value: number): void;
  23022. /**
  23023. * Specifically change the body's mass option. Won't recreate the physics body object
  23024. * @param mass The mass of the physics imposter
  23025. */
  23026. setMass(mass: number): void;
  23027. /**
  23028. * Gets the linear velocity
  23029. * @returns linear velocity or null
  23030. */
  23031. getLinearVelocity(): Nullable<Vector3>;
  23032. /**
  23033. * Sets the linear velocity
  23034. * @param velocity linear velocity or null
  23035. */
  23036. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23037. /**
  23038. * Gets the angular velocity
  23039. * @returns angular velocity or null
  23040. */
  23041. getAngularVelocity(): Nullable<Vector3>;
  23042. /**
  23043. * Sets the angular velocity
  23044. * @param velocity The velocity or null
  23045. */
  23046. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23047. /**
  23048. * Execute a function with the physics plugin native code
  23049. * Provide a function the will have two variables - the world object and the physics body object
  23050. * @param func The function to execute with the physics plugin native code
  23051. */
  23052. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23053. /**
  23054. * Register a function that will be executed before the physics world is stepping forward
  23055. * @param func The function to execute before the physics world is stepped forward
  23056. */
  23057. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23058. /**
  23059. * Unregister a function that will be executed before the physics world is stepping forward
  23060. * @param func The function to execute before the physics world is stepped forward
  23061. */
  23062. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23063. /**
  23064. * Register a function that will be executed after the physics step
  23065. * @param func The function to execute after physics step
  23066. */
  23067. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23068. /**
  23069. * Unregisters a function that will be executed after the physics step
  23070. * @param func The function to execute after physics step
  23071. */
  23072. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23073. /**
  23074. * register a function that will be executed when this impostor collides against a different body
  23075. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23076. * @param func Callback that is executed on collision
  23077. */
  23078. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23079. /**
  23080. * Unregisters the physics imposter on contact
  23081. * @param collideAgainst The physics object to collide against
  23082. * @param func Callback to execute on collision
  23083. */
  23084. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23085. private _tmpQuat;
  23086. private _tmpQuat2;
  23087. /**
  23088. * Get the parent rotation
  23089. * @returns The parent rotation
  23090. */
  23091. getParentsRotation(): Quaternion;
  23092. /**
  23093. * this function is executed by the physics engine.
  23094. */
  23095. beforeStep: () => void;
  23096. /**
  23097. * this function is executed by the physics engine
  23098. */
  23099. afterStep: () => void;
  23100. /**
  23101. * Legacy collision detection event support
  23102. */
  23103. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23104. /**
  23105. * event and body object due to cannon's event-based architecture.
  23106. */
  23107. onCollide: (e: {
  23108. body: any;
  23109. }) => void;
  23110. /**
  23111. * Apply a force
  23112. * @param force The force to apply
  23113. * @param contactPoint The contact point for the force
  23114. * @returns The physics imposter
  23115. */
  23116. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23117. /**
  23118. * Apply an impulse
  23119. * @param force The impulse force
  23120. * @param contactPoint The contact point for the impulse force
  23121. * @returns The physics imposter
  23122. */
  23123. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23124. /**
  23125. * A help function to create a joint
  23126. * @param otherImpostor A physics imposter used to create a joint
  23127. * @param jointType The type of joint
  23128. * @param jointData The data for the joint
  23129. * @returns The physics imposter
  23130. */
  23131. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23132. /**
  23133. * Add a joint to this impostor with a different impostor
  23134. * @param otherImpostor A physics imposter used to add a joint
  23135. * @param joint The joint to add
  23136. * @returns The physics imposter
  23137. */
  23138. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23139. /**
  23140. * Add an anchor to a cloth impostor
  23141. * @param otherImpostor rigid impostor to anchor to
  23142. * @param width ratio across width from 0 to 1
  23143. * @param height ratio up height from 0 to 1
  23144. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23145. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23146. * @returns impostor the soft imposter
  23147. */
  23148. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23149. /**
  23150. * Add a hook to a rope impostor
  23151. * @param otherImpostor rigid impostor to anchor to
  23152. * @param length ratio across rope from 0 to 1
  23153. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23154. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23155. * @returns impostor the rope imposter
  23156. */
  23157. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23158. /**
  23159. * Will keep this body still, in a sleep mode.
  23160. * @returns the physics imposter
  23161. */
  23162. sleep(): PhysicsImpostor;
  23163. /**
  23164. * Wake the body up.
  23165. * @returns The physics imposter
  23166. */
  23167. wakeUp(): PhysicsImpostor;
  23168. /**
  23169. * Clones the physics imposter
  23170. * @param newObject The physics imposter clones to this physics-enabled object
  23171. * @returns A nullable physics imposter
  23172. */
  23173. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23174. /**
  23175. * Disposes the physics imposter
  23176. */
  23177. dispose(): void;
  23178. /**
  23179. * Sets the delta position
  23180. * @param position The delta position amount
  23181. */
  23182. setDeltaPosition(position: Vector3): void;
  23183. /**
  23184. * Sets the delta rotation
  23185. * @param rotation The delta rotation amount
  23186. */
  23187. setDeltaRotation(rotation: Quaternion): void;
  23188. /**
  23189. * Gets the box size of the physics imposter and stores the result in the input parameter
  23190. * @param result Stores the box size
  23191. * @returns The physics imposter
  23192. */
  23193. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23194. /**
  23195. * Gets the radius of the physics imposter
  23196. * @returns Radius of the physics imposter
  23197. */
  23198. getRadius(): number;
  23199. /**
  23200. * Sync a bone with this impostor
  23201. * @param bone The bone to sync to the impostor.
  23202. * @param boneMesh The mesh that the bone is influencing.
  23203. * @param jointPivot The pivot of the joint / bone in local space.
  23204. * @param distToJoint Optional distance from the impostor to the joint.
  23205. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23206. */
  23207. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23208. /**
  23209. * Sync impostor to a bone
  23210. * @param bone The bone that the impostor will be synced to.
  23211. * @param boneMesh The mesh that the bone is influencing.
  23212. * @param jointPivot The pivot of the joint / bone in local space.
  23213. * @param distToJoint Optional distance from the impostor to the joint.
  23214. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23215. * @param boneAxis Optional vector3 axis the bone is aligned with
  23216. */
  23217. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23218. /**
  23219. * No-Imposter type
  23220. */
  23221. static NoImpostor: number;
  23222. /**
  23223. * Sphere-Imposter type
  23224. */
  23225. static SphereImpostor: number;
  23226. /**
  23227. * Box-Imposter type
  23228. */
  23229. static BoxImpostor: number;
  23230. /**
  23231. * Plane-Imposter type
  23232. */
  23233. static PlaneImpostor: number;
  23234. /**
  23235. * Mesh-imposter type
  23236. */
  23237. static MeshImpostor: number;
  23238. /**
  23239. * Capsule-Impostor type (Ammo.js plugin only)
  23240. */
  23241. static CapsuleImpostor: number;
  23242. /**
  23243. * Cylinder-Imposter type
  23244. */
  23245. static CylinderImpostor: number;
  23246. /**
  23247. * Particle-Imposter type
  23248. */
  23249. static ParticleImpostor: number;
  23250. /**
  23251. * Heightmap-Imposter type
  23252. */
  23253. static HeightmapImpostor: number;
  23254. /**
  23255. * ConvexHull-Impostor type (Ammo.js plugin only)
  23256. */
  23257. static ConvexHullImpostor: number;
  23258. /**
  23259. * Rope-Imposter type
  23260. */
  23261. static RopeImpostor: number;
  23262. /**
  23263. * Cloth-Imposter type
  23264. */
  23265. static ClothImpostor: number;
  23266. /**
  23267. * Softbody-Imposter type
  23268. */
  23269. static SoftbodyImpostor: number;
  23270. }
  23271. }
  23272. declare module BABYLON {
  23273. /**
  23274. * @hidden
  23275. **/
  23276. export class _CreationDataStorage {
  23277. closePath?: boolean;
  23278. closeArray?: boolean;
  23279. idx: number[];
  23280. dashSize: number;
  23281. gapSize: number;
  23282. path3D: Path3D;
  23283. pathArray: Vector3[][];
  23284. arc: number;
  23285. radius: number;
  23286. cap: number;
  23287. tessellation: number;
  23288. }
  23289. /**
  23290. * @hidden
  23291. **/
  23292. class _InstanceDataStorage {
  23293. visibleInstances: any;
  23294. batchCache: _InstancesBatch;
  23295. instancesBufferSize: number;
  23296. instancesBuffer: Nullable<Buffer>;
  23297. instancesData: Float32Array;
  23298. overridenInstanceCount: number;
  23299. isFrozen: boolean;
  23300. previousBatch: Nullable<_InstancesBatch>;
  23301. hardwareInstancedRendering: boolean;
  23302. sideOrientation: number;
  23303. }
  23304. /**
  23305. * @hidden
  23306. **/
  23307. export class _InstancesBatch {
  23308. mustReturn: boolean;
  23309. visibleInstances: Nullable<InstancedMesh[]>[];
  23310. renderSelf: boolean[];
  23311. hardwareInstancedRendering: boolean[];
  23312. }
  23313. /**
  23314. * Class used to represent renderable models
  23315. */
  23316. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23317. /**
  23318. * Mesh side orientation : usually the external or front surface
  23319. */
  23320. static readonly FRONTSIDE: number;
  23321. /**
  23322. * Mesh side orientation : usually the internal or back surface
  23323. */
  23324. static readonly BACKSIDE: number;
  23325. /**
  23326. * Mesh side orientation : both internal and external or front and back surfaces
  23327. */
  23328. static readonly DOUBLESIDE: number;
  23329. /**
  23330. * Mesh side orientation : by default, `FRONTSIDE`
  23331. */
  23332. static readonly DEFAULTSIDE: number;
  23333. /**
  23334. * Mesh cap setting : no cap
  23335. */
  23336. static readonly NO_CAP: number;
  23337. /**
  23338. * Mesh cap setting : one cap at the beginning of the mesh
  23339. */
  23340. static readonly CAP_START: number;
  23341. /**
  23342. * Mesh cap setting : one cap at the end of the mesh
  23343. */
  23344. static readonly CAP_END: number;
  23345. /**
  23346. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23347. */
  23348. static readonly CAP_ALL: number;
  23349. /**
  23350. * Mesh pattern setting : no flip or rotate
  23351. */
  23352. static readonly NO_FLIP: number;
  23353. /**
  23354. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23355. */
  23356. static readonly FLIP_TILE: number;
  23357. /**
  23358. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23359. */
  23360. static readonly ROTATE_TILE: number;
  23361. /**
  23362. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23363. */
  23364. static readonly FLIP_ROW: number;
  23365. /**
  23366. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23367. */
  23368. static readonly ROTATE_ROW: number;
  23369. /**
  23370. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23371. */
  23372. static readonly FLIP_N_ROTATE_TILE: number;
  23373. /**
  23374. * Mesh pattern setting : rotate pattern and rotate
  23375. */
  23376. static readonly FLIP_N_ROTATE_ROW: number;
  23377. /**
  23378. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23379. */
  23380. static readonly CENTER: number;
  23381. /**
  23382. * Mesh tile positioning : part tiles on left
  23383. */
  23384. static readonly LEFT: number;
  23385. /**
  23386. * Mesh tile positioning : part tiles on right
  23387. */
  23388. static readonly RIGHT: number;
  23389. /**
  23390. * Mesh tile positioning : part tiles on top
  23391. */
  23392. static readonly TOP: number;
  23393. /**
  23394. * Mesh tile positioning : part tiles on bottom
  23395. */
  23396. static readonly BOTTOM: number;
  23397. /**
  23398. * Gets the default side orientation.
  23399. * @param orientation the orientation to value to attempt to get
  23400. * @returns the default orientation
  23401. * @hidden
  23402. */
  23403. static _GetDefaultSideOrientation(orientation?: number): number;
  23404. private _internalMeshDataInfo;
  23405. /**
  23406. * An event triggered before rendering the mesh
  23407. */
  23408. readonly onBeforeRenderObservable: Observable<Mesh>;
  23409. /**
  23410. * An event triggered before binding the mesh
  23411. */
  23412. readonly onBeforeBindObservable: Observable<Mesh>;
  23413. /**
  23414. * An event triggered after rendering the mesh
  23415. */
  23416. readonly onAfterRenderObservable: Observable<Mesh>;
  23417. /**
  23418. * An event triggered before drawing the mesh
  23419. */
  23420. readonly onBeforeDrawObservable: Observable<Mesh>;
  23421. private _onBeforeDrawObserver;
  23422. /**
  23423. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23424. */
  23425. onBeforeDraw: () => void;
  23426. readonly hasInstances: boolean;
  23427. /**
  23428. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23429. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23430. */
  23431. delayLoadState: number;
  23432. /**
  23433. * Gets the list of instances created from this mesh
  23434. * it is not supposed to be modified manually.
  23435. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23437. */
  23438. instances: InstancedMesh[];
  23439. /**
  23440. * Gets the file containing delay loading data for this mesh
  23441. */
  23442. delayLoadingFile: string;
  23443. /** @hidden */
  23444. _binaryInfo: any;
  23445. /**
  23446. * User defined function used to change how LOD level selection is done
  23447. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23448. */
  23449. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23450. /**
  23451. * Gets or sets the morph target manager
  23452. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23453. */
  23454. morphTargetManager: Nullable<MorphTargetManager>;
  23455. /** @hidden */
  23456. _creationDataStorage: Nullable<_CreationDataStorage>;
  23457. /** @hidden */
  23458. _geometry: Nullable<Geometry>;
  23459. /** @hidden */
  23460. _delayInfo: Array<string>;
  23461. /** @hidden */
  23462. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23463. /** @hidden */
  23464. _instanceDataStorage: _InstanceDataStorage;
  23465. private _effectiveMaterial;
  23466. /** @hidden */
  23467. _shouldGenerateFlatShading: boolean;
  23468. /** @hidden */
  23469. _originalBuilderSideOrientation: number;
  23470. /**
  23471. * Use this property to change the original side orientation defined at construction time
  23472. */
  23473. overrideMaterialSideOrientation: Nullable<number>;
  23474. /**
  23475. * Gets the source mesh (the one used to clone this one from)
  23476. */
  23477. readonly source: Nullable<Mesh>;
  23478. /**
  23479. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23480. */
  23481. isUnIndexed: boolean;
  23482. /**
  23483. * @constructor
  23484. * @param name The value used by scene.getMeshByName() to do a lookup.
  23485. * @param scene The scene to add this mesh to.
  23486. * @param parent The parent of this mesh, if it has one
  23487. * @param source An optional Mesh from which geometry is shared, cloned.
  23488. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23489. * When false, achieved by calling a clone(), also passing False.
  23490. * This will make creation of children, recursive.
  23491. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23492. */
  23493. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23494. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23495. /**
  23496. * Gets the class name
  23497. * @returns the string "Mesh".
  23498. */
  23499. getClassName(): string;
  23500. /** @hidden */
  23501. readonly _isMesh: boolean;
  23502. /**
  23503. * Returns a description of this mesh
  23504. * @param fullDetails define if full details about this mesh must be used
  23505. * @returns a descriptive string representing this mesh
  23506. */
  23507. toString(fullDetails?: boolean): string;
  23508. /** @hidden */
  23509. _unBindEffect(): void;
  23510. /**
  23511. * Gets a boolean indicating if this mesh has LOD
  23512. */
  23513. readonly hasLODLevels: boolean;
  23514. /**
  23515. * Gets the list of MeshLODLevel associated with the current mesh
  23516. * @returns an array of MeshLODLevel
  23517. */
  23518. getLODLevels(): MeshLODLevel[];
  23519. private _sortLODLevels;
  23520. /**
  23521. * Add a mesh as LOD level triggered at the given distance.
  23522. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23523. * @param distance The distance from the center of the object to show this level
  23524. * @param mesh The mesh to be added as LOD level (can be null)
  23525. * @return This mesh (for chaining)
  23526. */
  23527. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23528. /**
  23529. * Returns the LOD level mesh at the passed distance or null if not found.
  23530. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23531. * @param distance The distance from the center of the object to show this level
  23532. * @returns a Mesh or `null`
  23533. */
  23534. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23535. /**
  23536. * Remove a mesh from the LOD array
  23537. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23538. * @param mesh defines the mesh to be removed
  23539. * @return This mesh (for chaining)
  23540. */
  23541. removeLODLevel(mesh: Mesh): Mesh;
  23542. /**
  23543. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23544. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23545. * @param camera defines the camera to use to compute distance
  23546. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23547. * @return This mesh (for chaining)
  23548. */
  23549. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23550. /**
  23551. * Gets the mesh internal Geometry object
  23552. */
  23553. readonly geometry: Nullable<Geometry>;
  23554. /**
  23555. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23556. * @returns the total number of vertices
  23557. */
  23558. getTotalVertices(): number;
  23559. /**
  23560. * Returns the content of an associated vertex buffer
  23561. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23562. * - VertexBuffer.PositionKind
  23563. * - VertexBuffer.UVKind
  23564. * - VertexBuffer.UV2Kind
  23565. * - VertexBuffer.UV3Kind
  23566. * - VertexBuffer.UV4Kind
  23567. * - VertexBuffer.UV5Kind
  23568. * - VertexBuffer.UV6Kind
  23569. * - VertexBuffer.ColorKind
  23570. * - VertexBuffer.MatricesIndicesKind
  23571. * - VertexBuffer.MatricesIndicesExtraKind
  23572. * - VertexBuffer.MatricesWeightsKind
  23573. * - VertexBuffer.MatricesWeightsExtraKind
  23574. * @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
  23575. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23576. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23577. */
  23578. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23579. /**
  23580. * Returns the mesh VertexBuffer object from the requested `kind`
  23581. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23582. * - VertexBuffer.PositionKind
  23583. * - VertexBuffer.NormalKind
  23584. * - VertexBuffer.UVKind
  23585. * - VertexBuffer.UV2Kind
  23586. * - VertexBuffer.UV3Kind
  23587. * - VertexBuffer.UV4Kind
  23588. * - VertexBuffer.UV5Kind
  23589. * - VertexBuffer.UV6Kind
  23590. * - VertexBuffer.ColorKind
  23591. * - VertexBuffer.MatricesIndicesKind
  23592. * - VertexBuffer.MatricesIndicesExtraKind
  23593. * - VertexBuffer.MatricesWeightsKind
  23594. * - VertexBuffer.MatricesWeightsExtraKind
  23595. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23596. */
  23597. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23598. /**
  23599. * Tests if a specific vertex buffer is associated with this mesh
  23600. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23601. * - VertexBuffer.PositionKind
  23602. * - VertexBuffer.NormalKind
  23603. * - VertexBuffer.UVKind
  23604. * - VertexBuffer.UV2Kind
  23605. * - VertexBuffer.UV3Kind
  23606. * - VertexBuffer.UV4Kind
  23607. * - VertexBuffer.UV5Kind
  23608. * - VertexBuffer.UV6Kind
  23609. * - VertexBuffer.ColorKind
  23610. * - VertexBuffer.MatricesIndicesKind
  23611. * - VertexBuffer.MatricesIndicesExtraKind
  23612. * - VertexBuffer.MatricesWeightsKind
  23613. * - VertexBuffer.MatricesWeightsExtraKind
  23614. * @returns a boolean
  23615. */
  23616. isVerticesDataPresent(kind: string): boolean;
  23617. /**
  23618. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23619. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23620. * - VertexBuffer.PositionKind
  23621. * - VertexBuffer.UVKind
  23622. * - VertexBuffer.UV2Kind
  23623. * - VertexBuffer.UV3Kind
  23624. * - VertexBuffer.UV4Kind
  23625. * - VertexBuffer.UV5Kind
  23626. * - VertexBuffer.UV6Kind
  23627. * - VertexBuffer.ColorKind
  23628. * - VertexBuffer.MatricesIndicesKind
  23629. * - VertexBuffer.MatricesIndicesExtraKind
  23630. * - VertexBuffer.MatricesWeightsKind
  23631. * - VertexBuffer.MatricesWeightsExtraKind
  23632. * @returns a boolean
  23633. */
  23634. isVertexBufferUpdatable(kind: string): boolean;
  23635. /**
  23636. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23637. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23638. * - VertexBuffer.PositionKind
  23639. * - VertexBuffer.NormalKind
  23640. * - VertexBuffer.UVKind
  23641. * - VertexBuffer.UV2Kind
  23642. * - VertexBuffer.UV3Kind
  23643. * - VertexBuffer.UV4Kind
  23644. * - VertexBuffer.UV5Kind
  23645. * - VertexBuffer.UV6Kind
  23646. * - VertexBuffer.ColorKind
  23647. * - VertexBuffer.MatricesIndicesKind
  23648. * - VertexBuffer.MatricesIndicesExtraKind
  23649. * - VertexBuffer.MatricesWeightsKind
  23650. * - VertexBuffer.MatricesWeightsExtraKind
  23651. * @returns an array of strings
  23652. */
  23653. getVerticesDataKinds(): string[];
  23654. /**
  23655. * Returns a positive integer : the total number of indices in this mesh geometry.
  23656. * @returns the numner of indices or zero if the mesh has no geometry.
  23657. */
  23658. getTotalIndices(): number;
  23659. /**
  23660. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23661. * @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.
  23662. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23663. * @returns the indices array or an empty array if the mesh has no geometry
  23664. */
  23665. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23666. readonly isBlocked: boolean;
  23667. /**
  23668. * Determine if the current mesh is ready to be rendered
  23669. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23670. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23671. * @returns true if all associated assets are ready (material, textures, shaders)
  23672. */
  23673. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23674. /**
  23675. * 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.
  23676. */
  23677. readonly areNormalsFrozen: boolean;
  23678. /**
  23679. * 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.
  23680. * @returns the current mesh
  23681. */
  23682. freezeNormals(): Mesh;
  23683. /**
  23684. * 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
  23685. * @returns the current mesh
  23686. */
  23687. unfreezeNormals(): Mesh;
  23688. /**
  23689. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23690. */
  23691. overridenInstanceCount: number;
  23692. /** @hidden */
  23693. _preActivate(): Mesh;
  23694. /** @hidden */
  23695. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23696. /** @hidden */
  23697. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23698. /**
  23699. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23700. * This means the mesh underlying bounding box and sphere are recomputed.
  23701. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23702. * @returns the current mesh
  23703. */
  23704. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23705. /** @hidden */
  23706. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23707. /**
  23708. * This function will subdivide the mesh into multiple submeshes
  23709. * @param count defines the expected number of submeshes
  23710. */
  23711. subdivide(count: number): void;
  23712. /**
  23713. * Copy a FloatArray into a specific associated vertex buffer
  23714. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23715. * - VertexBuffer.PositionKind
  23716. * - VertexBuffer.UVKind
  23717. * - VertexBuffer.UV2Kind
  23718. * - VertexBuffer.UV3Kind
  23719. * - VertexBuffer.UV4Kind
  23720. * - VertexBuffer.UV5Kind
  23721. * - VertexBuffer.UV6Kind
  23722. * - VertexBuffer.ColorKind
  23723. * - VertexBuffer.MatricesIndicesKind
  23724. * - VertexBuffer.MatricesIndicesExtraKind
  23725. * - VertexBuffer.MatricesWeightsKind
  23726. * - VertexBuffer.MatricesWeightsExtraKind
  23727. * @param data defines the data source
  23728. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23729. * @param stride defines the data stride size (can be null)
  23730. * @returns the current mesh
  23731. */
  23732. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23733. /**
  23734. * Flags an associated vertex buffer as updatable
  23735. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23736. * - VertexBuffer.PositionKind
  23737. * - VertexBuffer.UVKind
  23738. * - VertexBuffer.UV2Kind
  23739. * - VertexBuffer.UV3Kind
  23740. * - VertexBuffer.UV4Kind
  23741. * - VertexBuffer.UV5Kind
  23742. * - VertexBuffer.UV6Kind
  23743. * - VertexBuffer.ColorKind
  23744. * - VertexBuffer.MatricesIndicesKind
  23745. * - VertexBuffer.MatricesIndicesExtraKind
  23746. * - VertexBuffer.MatricesWeightsKind
  23747. * - VertexBuffer.MatricesWeightsExtraKind
  23748. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23749. */
  23750. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23751. /**
  23752. * Sets the mesh global Vertex Buffer
  23753. * @param buffer defines the buffer to use
  23754. * @returns the current mesh
  23755. */
  23756. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23757. /**
  23758. * Update a specific associated vertex buffer
  23759. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23760. * - VertexBuffer.PositionKind
  23761. * - VertexBuffer.UVKind
  23762. * - VertexBuffer.UV2Kind
  23763. * - VertexBuffer.UV3Kind
  23764. * - VertexBuffer.UV4Kind
  23765. * - VertexBuffer.UV5Kind
  23766. * - VertexBuffer.UV6Kind
  23767. * - VertexBuffer.ColorKind
  23768. * - VertexBuffer.MatricesIndicesKind
  23769. * - VertexBuffer.MatricesIndicesExtraKind
  23770. * - VertexBuffer.MatricesWeightsKind
  23771. * - VertexBuffer.MatricesWeightsExtraKind
  23772. * @param data defines the data source
  23773. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23774. * @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)
  23775. * @returns the current mesh
  23776. */
  23777. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23778. /**
  23779. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23780. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23781. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23782. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23783. * @returns the current mesh
  23784. */
  23785. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23786. /**
  23787. * Creates a un-shared specific occurence of the geometry for the mesh.
  23788. * @returns the current mesh
  23789. */
  23790. makeGeometryUnique(): Mesh;
  23791. /**
  23792. * Set the index buffer of this mesh
  23793. * @param indices defines the source data
  23794. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23795. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23796. * @returns the current mesh
  23797. */
  23798. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23799. /**
  23800. * Update the current index buffer
  23801. * @param indices defines the source data
  23802. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23803. * @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)
  23804. * @returns the current mesh
  23805. */
  23806. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23807. /**
  23808. * Invert the geometry to move from a right handed system to a left handed one.
  23809. * @returns the current mesh
  23810. */
  23811. toLeftHanded(): Mesh;
  23812. /** @hidden */
  23813. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23814. /** @hidden */
  23815. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23816. /**
  23817. * Registers for this mesh a javascript function called just before the rendering process
  23818. * @param func defines the function to call before rendering this mesh
  23819. * @returns the current mesh
  23820. */
  23821. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23822. /**
  23823. * Disposes a previously registered javascript function called before the rendering
  23824. * @param func defines the function to remove
  23825. * @returns the current mesh
  23826. */
  23827. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23828. /**
  23829. * Registers for this mesh a javascript function called just after the rendering is complete
  23830. * @param func defines the function to call after rendering this mesh
  23831. * @returns the current mesh
  23832. */
  23833. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23834. /**
  23835. * Disposes a previously registered javascript function called after the rendering.
  23836. * @param func defines the function to remove
  23837. * @returns the current mesh
  23838. */
  23839. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23840. /** @hidden */
  23841. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23842. /** @hidden */
  23843. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23844. /** @hidden */
  23845. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23846. /** @hidden */
  23847. _rebuild(): void;
  23848. /** @hidden */
  23849. _freeze(): void;
  23850. /** @hidden */
  23851. _unFreeze(): void;
  23852. /**
  23853. * 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
  23854. * @param subMesh defines the subMesh to render
  23855. * @param enableAlphaMode defines if alpha mode can be changed
  23856. * @returns the current mesh
  23857. */
  23858. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23859. private _onBeforeDraw;
  23860. /**
  23861. * Renormalize the mesh and patch it up if there are no weights
  23862. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23863. * However in the case of zero weights then we set just a single influence to 1.
  23864. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23865. */
  23866. cleanMatrixWeights(): void;
  23867. private normalizeSkinFourWeights;
  23868. private normalizeSkinWeightsAndExtra;
  23869. /**
  23870. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23871. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23872. * the user know there was an issue with importing the mesh
  23873. * @returns a validation object with skinned, valid and report string
  23874. */
  23875. validateSkinning(): {
  23876. skinned: boolean;
  23877. valid: boolean;
  23878. report: string;
  23879. };
  23880. /** @hidden */
  23881. _checkDelayState(): Mesh;
  23882. private _queueLoad;
  23883. /**
  23884. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23885. * A mesh is in the frustum if its bounding box intersects the frustum
  23886. * @param frustumPlanes defines the frustum to test
  23887. * @returns true if the mesh is in the frustum planes
  23888. */
  23889. isInFrustum(frustumPlanes: Plane[]): boolean;
  23890. /**
  23891. * Sets the mesh material by the material or multiMaterial `id` property
  23892. * @param id is a string identifying the material or the multiMaterial
  23893. * @returns the current mesh
  23894. */
  23895. setMaterialByID(id: string): Mesh;
  23896. /**
  23897. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23898. * @returns an array of IAnimatable
  23899. */
  23900. getAnimatables(): IAnimatable[];
  23901. /**
  23902. * Modifies the mesh geometry according to the passed transformation matrix.
  23903. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23904. * The mesh normals are modified using the same transformation.
  23905. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23906. * @param transform defines the transform matrix to use
  23907. * @see http://doc.babylonjs.com/resources/baking_transformations
  23908. * @returns the current mesh
  23909. */
  23910. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23911. /**
  23912. * Modifies the mesh geometry according to its own current World Matrix.
  23913. * The mesh World Matrix is then reset.
  23914. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23915. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23916. * @see http://doc.babylonjs.com/resources/baking_transformations
  23917. * @returns the current mesh
  23918. */
  23919. bakeCurrentTransformIntoVertices(): Mesh;
  23920. /** @hidden */
  23921. readonly _positions: Nullable<Vector3[]>;
  23922. /** @hidden */
  23923. _resetPointsArrayCache(): Mesh;
  23924. /** @hidden */
  23925. _generatePointsArray(): boolean;
  23926. /**
  23927. * Returns a new Mesh object generated from the current mesh properties.
  23928. * This method must not get confused with createInstance()
  23929. * @param name is a string, the name given to the new mesh
  23930. * @param newParent can be any Node object (default `null`)
  23931. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23932. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23933. * @returns a new mesh
  23934. */
  23935. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23936. /**
  23937. * Releases resources associated with this mesh.
  23938. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23939. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23940. */
  23941. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23942. /**
  23943. * Modifies the mesh geometry according to a displacement map.
  23944. * 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.
  23945. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23946. * @param url is a string, the URL from the image file is to be downloaded.
  23947. * @param minHeight is the lower limit of the displacement.
  23948. * @param maxHeight is the upper limit of the displacement.
  23949. * @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.
  23950. * @param uvOffset is an optional vector2 used to offset UV.
  23951. * @param uvScale is an optional vector2 used to scale UV.
  23952. * @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.
  23953. * @returns the Mesh.
  23954. */
  23955. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23956. /**
  23957. * Modifies the mesh geometry according to a displacementMap buffer.
  23958. * 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.
  23959. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23960. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23961. * @param heightMapWidth is the width of the buffer image.
  23962. * @param heightMapHeight is the height of the buffer image.
  23963. * @param minHeight is the lower limit of the displacement.
  23964. * @param maxHeight is the upper limit of the displacement.
  23965. * @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.
  23966. * @param uvOffset is an optional vector2 used to offset UV.
  23967. * @param uvScale is an optional vector2 used to scale UV.
  23968. * @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.
  23969. * @returns the Mesh.
  23970. */
  23971. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23972. /**
  23973. * Modify the mesh to get a flat shading rendering.
  23974. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23975. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23976. * @returns current mesh
  23977. */
  23978. convertToFlatShadedMesh(): Mesh;
  23979. /**
  23980. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23981. * In other words, more vertices, no more indices and a single bigger VBO.
  23982. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23983. * @returns current mesh
  23984. */
  23985. convertToUnIndexedMesh(): Mesh;
  23986. /**
  23987. * Inverses facet orientations.
  23988. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23989. * @param flipNormals will also inverts the normals
  23990. * @returns current mesh
  23991. */
  23992. flipFaces(flipNormals?: boolean): Mesh;
  23993. /**
  23994. * Increase the number of facets and hence vertices in a mesh
  23995. * Vertex normals are interpolated from existing vertex normals
  23996. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23997. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23998. */
  23999. increaseVertices(numberPerEdge: number): void;
  24000. /**
  24001. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24002. * This will undo any application of covertToFlatShadedMesh
  24003. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24004. */
  24005. forceSharedVertices(): void;
  24006. /** @hidden */
  24007. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24008. /** @hidden */
  24009. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24010. /**
  24011. * Creates a new InstancedMesh object from the mesh model.
  24012. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24013. * @param name defines the name of the new instance
  24014. * @returns a new InstancedMesh
  24015. */
  24016. createInstance(name: string): InstancedMesh;
  24017. /**
  24018. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24019. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24020. * @returns the current mesh
  24021. */
  24022. synchronizeInstances(): Mesh;
  24023. /**
  24024. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24025. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24026. * This should be used together with the simplification to avoid disappearing triangles.
  24027. * @param successCallback an optional success callback to be called after the optimization finished.
  24028. * @returns the current mesh
  24029. */
  24030. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24031. /**
  24032. * Serialize current mesh
  24033. * @param serializationObject defines the object which will receive the serialization data
  24034. */
  24035. serialize(serializationObject: any): void;
  24036. /** @hidden */
  24037. _syncGeometryWithMorphTargetManager(): void;
  24038. /** @hidden */
  24039. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24040. /**
  24041. * Returns a new Mesh object parsed from the source provided.
  24042. * @param parsedMesh is the source
  24043. * @param scene defines the hosting scene
  24044. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24045. * @returns a new Mesh
  24046. */
  24047. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24048. /**
  24049. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24050. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24051. * @param name defines the name of the mesh to create
  24052. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24053. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24054. * @param closePath creates a seam between the first and the last points of each path of the path array
  24055. * @param offset is taken in account only if the `pathArray` is containing a single path
  24056. * @param scene defines the hosting scene
  24057. * @param updatable defines if the mesh must be flagged as updatable
  24058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24059. * @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)
  24060. * @returns a new Mesh
  24061. */
  24062. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24063. /**
  24064. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24065. * @param name defines the name of the mesh to create
  24066. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24067. * @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
  24068. * @param scene defines the hosting scene
  24069. * @param updatable defines if the mesh must be flagged as updatable
  24070. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24071. * @returns a new Mesh
  24072. */
  24073. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24074. /**
  24075. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24076. * @param name defines the name of the mesh to create
  24077. * @param size sets the size (float) of each box side (default 1)
  24078. * @param scene defines the hosting scene
  24079. * @param updatable defines if the mesh must be flagged as updatable
  24080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24081. * @returns a new Mesh
  24082. */
  24083. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24084. /**
  24085. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24086. * @param name defines the name of the mesh to create
  24087. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24088. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24089. * @param scene defines the hosting scene
  24090. * @param updatable defines if the mesh must be flagged as updatable
  24091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24092. * @returns a new Mesh
  24093. */
  24094. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24095. /**
  24096. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24097. * @param name defines the name of the mesh to create
  24098. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24099. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24100. * @param scene defines the hosting scene
  24101. * @returns a new Mesh
  24102. */
  24103. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24104. /**
  24105. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24106. * @param name defines the name of the mesh to create
  24107. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24108. * @param diameterTop set the top cap diameter (floats, default 1)
  24109. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24110. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24111. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24112. * @param scene defines the hosting scene
  24113. * @param updatable defines if the mesh must be flagged as updatable
  24114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24115. * @returns a new Mesh
  24116. */
  24117. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24118. /**
  24119. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24120. * @param name defines the name of the mesh to create
  24121. * @param diameter sets the diameter size (float) of the torus (default 1)
  24122. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24123. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24124. * @param scene defines the hosting scene
  24125. * @param updatable defines if the mesh must be flagged as updatable
  24126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24127. * @returns a new Mesh
  24128. */
  24129. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24130. /**
  24131. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24132. * @param name defines the name of the mesh to create
  24133. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24134. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24135. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24136. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24137. * @param p the number of windings on X axis (positive integers, default 2)
  24138. * @param q the number of windings on Y axis (positive integers, default 3)
  24139. * @param scene defines the hosting scene
  24140. * @param updatable defines if the mesh must be flagged as updatable
  24141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24142. * @returns a new Mesh
  24143. */
  24144. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24145. /**
  24146. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24147. * @param name defines the name of the mesh to create
  24148. * @param points is an array successive Vector3
  24149. * @param scene defines the hosting scene
  24150. * @param updatable defines if the mesh must be flagged as updatable
  24151. * @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).
  24152. * @returns a new Mesh
  24153. */
  24154. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24155. /**
  24156. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24157. * @param name defines the name of the mesh to create
  24158. * @param points is an array successive Vector3
  24159. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24160. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24161. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24162. * @param scene defines the hosting scene
  24163. * @param updatable defines if the mesh must be flagged as updatable
  24164. * @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)
  24165. * @returns a new Mesh
  24166. */
  24167. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24168. /**
  24169. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24170. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24171. * 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.
  24172. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24173. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24174. * Remember you can only change the shape positions, not their number when updating a polygon.
  24175. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24176. * @param name defines the name of the mesh to create
  24177. * @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
  24178. * @param scene defines the hosting scene
  24179. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24180. * @param updatable defines if the mesh must be flagged as updatable
  24181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24182. * @param earcutInjection can be used to inject your own earcut reference
  24183. * @returns a new Mesh
  24184. */
  24185. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24186. /**
  24187. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24188. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24189. * @param name defines the name of the mesh to create
  24190. * @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
  24191. * @param depth defines the height of extrusion
  24192. * @param scene defines the hosting scene
  24193. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24194. * @param updatable defines if the mesh must be flagged as updatable
  24195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24196. * @param earcutInjection can be used to inject your own earcut reference
  24197. * @returns a new Mesh
  24198. */
  24199. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24200. /**
  24201. * Creates an extruded shape mesh.
  24202. * 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
  24203. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24204. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24205. * @param name defines the name of the mesh to create
  24206. * @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
  24207. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24208. * @param scale is the value to scale the shape
  24209. * @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
  24210. * @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
  24211. * @param scene defines the hosting scene
  24212. * @param updatable defines if the mesh must be flagged as updatable
  24213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24214. * @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)
  24215. * @returns a new Mesh
  24216. */
  24217. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24218. /**
  24219. * Creates an custom extruded shape mesh.
  24220. * The custom extrusion is a parametric shape.
  24221. * It has no predefined shape. Its final shape will depend on the input parameters.
  24222. * Please consider using the same method from the MeshBuilder class instead
  24223. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24224. * @param name defines the name of the mesh to create
  24225. * @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
  24226. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24227. * @param scaleFunction is a custom Javascript function called on each path point
  24228. * @param rotationFunction is a custom Javascript function called on each path point
  24229. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24230. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24231. * @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
  24232. * @param scene defines the hosting scene
  24233. * @param updatable defines if the mesh must be flagged as updatable
  24234. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24235. * @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)
  24236. * @returns a new Mesh
  24237. */
  24238. 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;
  24239. /**
  24240. * Creates lathe mesh.
  24241. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24242. * Please consider using the same method from the MeshBuilder class instead
  24243. * @param name defines the name of the mesh to create
  24244. * @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
  24245. * @param radius is the radius value of the lathe
  24246. * @param tessellation is the side number of the lathe.
  24247. * @param scene defines the hosting scene
  24248. * @param updatable defines if the mesh must be flagged as updatable
  24249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24250. * @returns a new Mesh
  24251. */
  24252. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24253. /**
  24254. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24255. * @param name defines the name of the mesh to create
  24256. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24257. * @param scene defines the hosting scene
  24258. * @param updatable defines if the mesh must be flagged as updatable
  24259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24260. * @returns a new Mesh
  24261. */
  24262. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24263. /**
  24264. * Creates a ground mesh.
  24265. * Please consider using the same method from the MeshBuilder class instead
  24266. * @param name defines the name of the mesh to create
  24267. * @param width set the width of the ground
  24268. * @param height set the height of the ground
  24269. * @param subdivisions sets the number of subdivisions per side
  24270. * @param scene defines the hosting scene
  24271. * @param updatable defines if the mesh must be flagged as updatable
  24272. * @returns a new Mesh
  24273. */
  24274. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24275. /**
  24276. * Creates a tiled ground mesh.
  24277. * Please consider using the same method from the MeshBuilder class instead
  24278. * @param name defines the name of the mesh to create
  24279. * @param xmin set the ground minimum X coordinate
  24280. * @param zmin set the ground minimum Y coordinate
  24281. * @param xmax set the ground maximum X coordinate
  24282. * @param zmax set the ground maximum Z coordinate
  24283. * @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
  24284. * @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
  24285. * @param scene defines the hosting scene
  24286. * @param updatable defines if the mesh must be flagged as updatable
  24287. * @returns a new Mesh
  24288. */
  24289. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24290. w: number;
  24291. h: number;
  24292. }, precision: {
  24293. w: number;
  24294. h: number;
  24295. }, scene: Scene, updatable?: boolean): Mesh;
  24296. /**
  24297. * Creates a ground mesh from a height map.
  24298. * Please consider using the same method from the MeshBuilder class instead
  24299. * @see http://doc.babylonjs.com/babylon101/height_map
  24300. * @param name defines the name of the mesh to create
  24301. * @param url sets the URL of the height map image resource
  24302. * @param width set the ground width size
  24303. * @param height set the ground height size
  24304. * @param subdivisions sets the number of subdivision per side
  24305. * @param minHeight is the minimum altitude on the ground
  24306. * @param maxHeight is the maximum altitude on the ground
  24307. * @param scene defines the hosting scene
  24308. * @param updatable defines if the mesh must be flagged as updatable
  24309. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24310. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24311. * @returns a new Mesh
  24312. */
  24313. 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;
  24314. /**
  24315. * Creates a tube mesh.
  24316. * The tube is a parametric shape.
  24317. * It has no predefined shape. Its final shape will depend on the input parameters.
  24318. * Please consider using the same method from the MeshBuilder class instead
  24319. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24320. * @param name defines the name of the mesh to create
  24321. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24322. * @param radius sets the tube radius size
  24323. * @param tessellation is the number of sides on the tubular surface
  24324. * @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
  24325. * @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
  24326. * @param scene defines the hosting scene
  24327. * @param updatable defines if the mesh must be flagged as updatable
  24328. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24329. * @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)
  24330. * @returns a new Mesh
  24331. */
  24332. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24333. (i: number, distance: number): number;
  24334. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24335. /**
  24336. * Creates a polyhedron mesh.
  24337. * Please consider using the same method from the MeshBuilder class instead.
  24338. * * 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
  24339. * * The parameter `size` (positive float, default 1) sets the polygon size
  24340. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24341. * * 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`
  24342. * * 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
  24343. * * 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)`)
  24344. * * 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
  24345. * * 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
  24346. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24347. * * 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
  24348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24349. * @param name defines the name of the mesh to create
  24350. * @param options defines the options used to create the mesh
  24351. * @param scene defines the hosting scene
  24352. * @returns a new Mesh
  24353. */
  24354. static CreatePolyhedron(name: string, options: {
  24355. type?: number;
  24356. size?: number;
  24357. sizeX?: number;
  24358. sizeY?: number;
  24359. sizeZ?: number;
  24360. custom?: any;
  24361. faceUV?: Vector4[];
  24362. faceColors?: Color4[];
  24363. updatable?: boolean;
  24364. sideOrientation?: number;
  24365. }, scene: Scene): Mesh;
  24366. /**
  24367. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24368. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24369. * * 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`)
  24370. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24371. * * 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
  24372. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24373. * * 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
  24374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24375. * @param name defines the name of the mesh
  24376. * @param options defines the options used to create the mesh
  24377. * @param scene defines the hosting scene
  24378. * @returns a new Mesh
  24379. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24380. */
  24381. static CreateIcoSphere(name: string, options: {
  24382. radius?: number;
  24383. flat?: boolean;
  24384. subdivisions?: number;
  24385. sideOrientation?: number;
  24386. updatable?: boolean;
  24387. }, scene: Scene): Mesh;
  24388. /**
  24389. * Creates a decal mesh.
  24390. * Please consider using the same method from the MeshBuilder class instead.
  24391. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24392. * @param name defines the name of the mesh
  24393. * @param sourceMesh defines the mesh receiving the decal
  24394. * @param position sets the position of the decal in world coordinates
  24395. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24396. * @param size sets the decal scaling
  24397. * @param angle sets the angle to rotate the decal
  24398. * @returns a new Mesh
  24399. */
  24400. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24401. /**
  24402. * Prepare internal position array for software CPU skinning
  24403. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24404. */
  24405. setPositionsForCPUSkinning(): Float32Array;
  24406. /**
  24407. * Prepare internal normal array for software CPU skinning
  24408. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24409. */
  24410. setNormalsForCPUSkinning(): Float32Array;
  24411. /**
  24412. * Updates the vertex buffer by applying transformation from the bones
  24413. * @param skeleton defines the skeleton to apply to current mesh
  24414. * @returns the current mesh
  24415. */
  24416. applySkeleton(skeleton: Skeleton): Mesh;
  24417. /**
  24418. * 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
  24419. * @param meshes defines the list of meshes to scan
  24420. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24421. */
  24422. static MinMax(meshes: AbstractMesh[]): {
  24423. min: Vector3;
  24424. max: Vector3;
  24425. };
  24426. /**
  24427. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24428. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24429. * @returns a vector3
  24430. */
  24431. static Center(meshesOrMinMaxVector: {
  24432. min: Vector3;
  24433. max: Vector3;
  24434. } | AbstractMesh[]): Vector3;
  24435. /**
  24436. * Merge the array of meshes into a single mesh for performance reasons.
  24437. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24438. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24439. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24440. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24441. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24442. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24443. * @returns a new mesh
  24444. */
  24445. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24446. /** @hidden */
  24447. addInstance(instance: InstancedMesh): void;
  24448. /** @hidden */
  24449. removeInstance(instance: InstancedMesh): void;
  24450. }
  24451. }
  24452. declare module BABYLON {
  24453. /**
  24454. * This is the base class of all the camera used in the application.
  24455. * @see http://doc.babylonjs.com/features/cameras
  24456. */
  24457. export class Camera extends Node {
  24458. /** @hidden */
  24459. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24460. /**
  24461. * This is the default projection mode used by the cameras.
  24462. * It helps recreating a feeling of perspective and better appreciate depth.
  24463. * This is the best way to simulate real life cameras.
  24464. */
  24465. static readonly PERSPECTIVE_CAMERA: number;
  24466. /**
  24467. * This helps creating camera with an orthographic mode.
  24468. * 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.
  24469. */
  24470. static readonly ORTHOGRAPHIC_CAMERA: number;
  24471. /**
  24472. * This is the default FOV mode for perspective cameras.
  24473. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24474. */
  24475. static readonly FOVMODE_VERTICAL_FIXED: number;
  24476. /**
  24477. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24478. */
  24479. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24480. /**
  24481. * This specifies ther is no need for a camera rig.
  24482. * Basically only one eye is rendered corresponding to the camera.
  24483. */
  24484. static readonly RIG_MODE_NONE: number;
  24485. /**
  24486. * Simulates a camera Rig with one blue eye and one red eye.
  24487. * This can be use with 3d blue and red glasses.
  24488. */
  24489. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24490. /**
  24491. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24492. */
  24493. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24494. /**
  24495. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24496. */
  24497. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24498. /**
  24499. * Defines that both eyes of the camera will be rendered over under each other.
  24500. */
  24501. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24502. /**
  24503. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24504. */
  24505. static readonly RIG_MODE_VR: number;
  24506. /**
  24507. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24508. */
  24509. static readonly RIG_MODE_WEBVR: number;
  24510. /**
  24511. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24512. */
  24513. static readonly RIG_MODE_CUSTOM: number;
  24514. /**
  24515. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24516. */
  24517. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24518. /**
  24519. * Define the input manager associated with the camera.
  24520. */
  24521. inputs: CameraInputsManager<Camera>;
  24522. /** @hidden */
  24523. _position: Vector3;
  24524. /**
  24525. * Define the current local position of the camera in the scene
  24526. */
  24527. position: Vector3;
  24528. /**
  24529. * The vector the camera should consider as up.
  24530. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24531. */
  24532. upVector: Vector3;
  24533. /**
  24534. * Define the current limit on the left side for an orthographic camera
  24535. * In scene unit
  24536. */
  24537. orthoLeft: Nullable<number>;
  24538. /**
  24539. * Define the current limit on the right side for an orthographic camera
  24540. * In scene unit
  24541. */
  24542. orthoRight: Nullable<number>;
  24543. /**
  24544. * Define the current limit on the bottom side for an orthographic camera
  24545. * In scene unit
  24546. */
  24547. orthoBottom: Nullable<number>;
  24548. /**
  24549. * Define the current limit on the top side for an orthographic camera
  24550. * In scene unit
  24551. */
  24552. orthoTop: Nullable<number>;
  24553. /**
  24554. * Field Of View is set in Radians. (default is 0.8)
  24555. */
  24556. fov: number;
  24557. /**
  24558. * Define the minimum distance the camera can see from.
  24559. * This is important to note that the depth buffer are not infinite and the closer it starts
  24560. * the more your scene might encounter depth fighting issue.
  24561. */
  24562. minZ: number;
  24563. /**
  24564. * Define the maximum distance the camera can see to.
  24565. * This is important to note that the depth buffer are not infinite and the further it end
  24566. * the more your scene might encounter depth fighting issue.
  24567. */
  24568. maxZ: number;
  24569. /**
  24570. * Define the default inertia of the camera.
  24571. * This helps giving a smooth feeling to the camera movement.
  24572. */
  24573. inertia: number;
  24574. /**
  24575. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24576. */
  24577. mode: number;
  24578. /**
  24579. * Define wether the camera is intermediate.
  24580. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24581. */
  24582. isIntermediate: boolean;
  24583. /**
  24584. * Define the viewport of the camera.
  24585. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24586. */
  24587. viewport: Viewport;
  24588. /**
  24589. * Restricts the camera to viewing objects with the same layerMask.
  24590. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24591. */
  24592. layerMask: number;
  24593. /**
  24594. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24595. */
  24596. fovMode: number;
  24597. /**
  24598. * Rig mode of the camera.
  24599. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24600. * This is normally controlled byt the camera themselves as internal use.
  24601. */
  24602. cameraRigMode: number;
  24603. /**
  24604. * Defines the distance between both "eyes" in case of a RIG
  24605. */
  24606. interaxialDistance: number;
  24607. /**
  24608. * Defines if stereoscopic rendering is done side by side or over under.
  24609. */
  24610. isStereoscopicSideBySide: boolean;
  24611. /**
  24612. * 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
  24613. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24614. * else in the scene. (Eg. security camera)
  24615. *
  24616. * 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)
  24617. */
  24618. customRenderTargets: RenderTargetTexture[];
  24619. /**
  24620. * When set, the camera will render to this render target instead of the default canvas
  24621. *
  24622. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24623. */
  24624. outputRenderTarget: Nullable<RenderTargetTexture>;
  24625. /**
  24626. * Observable triggered when the camera view matrix has changed.
  24627. */
  24628. onViewMatrixChangedObservable: Observable<Camera>;
  24629. /**
  24630. * Observable triggered when the camera Projection matrix has changed.
  24631. */
  24632. onProjectionMatrixChangedObservable: Observable<Camera>;
  24633. /**
  24634. * Observable triggered when the inputs have been processed.
  24635. */
  24636. onAfterCheckInputsObservable: Observable<Camera>;
  24637. /**
  24638. * Observable triggered when reset has been called and applied to the camera.
  24639. */
  24640. onRestoreStateObservable: Observable<Camera>;
  24641. /** @hidden */
  24642. _cameraRigParams: any;
  24643. /** @hidden */
  24644. _rigCameras: Camera[];
  24645. /** @hidden */
  24646. _rigPostProcess: Nullable<PostProcess>;
  24647. protected _webvrViewMatrix: Matrix;
  24648. /** @hidden */
  24649. _skipRendering: boolean;
  24650. /** @hidden */
  24651. _projectionMatrix: Matrix;
  24652. /** @hidden */
  24653. _postProcesses: Nullable<PostProcess>[];
  24654. /** @hidden */
  24655. _activeMeshes: SmartArray<AbstractMesh>;
  24656. protected _globalPosition: Vector3;
  24657. /** @hidden */
  24658. _computedViewMatrix: Matrix;
  24659. private _doNotComputeProjectionMatrix;
  24660. private _transformMatrix;
  24661. private _frustumPlanes;
  24662. private _refreshFrustumPlanes;
  24663. private _storedFov;
  24664. private _stateStored;
  24665. /**
  24666. * Instantiates a new camera object.
  24667. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24668. * @see http://doc.babylonjs.com/features/cameras
  24669. * @param name Defines the name of the camera in the scene
  24670. * @param position Defines the position of the camera
  24671. * @param scene Defines the scene the camera belongs too
  24672. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24673. */
  24674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24675. /**
  24676. * Store current camera state (fov, position, etc..)
  24677. * @returns the camera
  24678. */
  24679. storeState(): Camera;
  24680. /**
  24681. * Restores the camera state values if it has been stored. You must call storeState() first
  24682. */
  24683. protected _restoreStateValues(): boolean;
  24684. /**
  24685. * Restored camera state. You must call storeState() first.
  24686. * @returns true if restored and false otherwise
  24687. */
  24688. restoreState(): boolean;
  24689. /**
  24690. * Gets the class name of the camera.
  24691. * @returns the class name
  24692. */
  24693. getClassName(): string;
  24694. /** @hidden */
  24695. readonly _isCamera: boolean;
  24696. /**
  24697. * Gets a string representation of the camera useful for debug purpose.
  24698. * @param fullDetails Defines that a more verboe level of logging is required
  24699. * @returns the string representation
  24700. */
  24701. toString(fullDetails?: boolean): string;
  24702. /**
  24703. * Gets the current world space position of the camera.
  24704. */
  24705. readonly globalPosition: Vector3;
  24706. /**
  24707. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24708. * @returns the active meshe list
  24709. */
  24710. getActiveMeshes(): SmartArray<AbstractMesh>;
  24711. /**
  24712. * Check wether a mesh is part of the current active mesh list of the camera
  24713. * @param mesh Defines the mesh to check
  24714. * @returns true if active, false otherwise
  24715. */
  24716. isActiveMesh(mesh: Mesh): boolean;
  24717. /**
  24718. * Is this camera ready to be used/rendered
  24719. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24720. * @return true if the camera is ready
  24721. */
  24722. isReady(completeCheck?: boolean): boolean;
  24723. /** @hidden */
  24724. _initCache(): void;
  24725. /** @hidden */
  24726. _updateCache(ignoreParentClass?: boolean): void;
  24727. /** @hidden */
  24728. _isSynchronized(): boolean;
  24729. /** @hidden */
  24730. _isSynchronizedViewMatrix(): boolean;
  24731. /** @hidden */
  24732. _isSynchronizedProjectionMatrix(): boolean;
  24733. /**
  24734. * Attach the input controls to a specific dom element to get the input from.
  24735. * @param element Defines the element the controls should be listened from
  24736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24737. */
  24738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24739. /**
  24740. * Detach the current controls from the specified dom element.
  24741. * @param element Defines the element to stop listening the inputs from
  24742. */
  24743. detachControl(element: HTMLElement): void;
  24744. /**
  24745. * Update the camera state according to the different inputs gathered during the frame.
  24746. */
  24747. update(): void;
  24748. /** @hidden */
  24749. _checkInputs(): void;
  24750. /** @hidden */
  24751. readonly rigCameras: Camera[];
  24752. /**
  24753. * Gets the post process used by the rig cameras
  24754. */
  24755. readonly rigPostProcess: Nullable<PostProcess>;
  24756. /**
  24757. * Internal, gets the first post proces.
  24758. * @returns the first post process to be run on this camera.
  24759. */
  24760. _getFirstPostProcess(): Nullable<PostProcess>;
  24761. private _cascadePostProcessesToRigCams;
  24762. /**
  24763. * Attach a post process to the camera.
  24764. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24765. * @param postProcess The post process to attach to the camera
  24766. * @param insertAt The position of the post process in case several of them are in use in the scene
  24767. * @returns the position the post process has been inserted at
  24768. */
  24769. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24770. /**
  24771. * Detach a post process to the camera.
  24772. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24773. * @param postProcess The post process to detach from the camera
  24774. */
  24775. detachPostProcess(postProcess: PostProcess): void;
  24776. /**
  24777. * Gets the current world matrix of the camera
  24778. */
  24779. getWorldMatrix(): Matrix;
  24780. /** @hidden */
  24781. _getViewMatrix(): Matrix;
  24782. /**
  24783. * Gets the current view matrix of the camera.
  24784. * @param force forces the camera to recompute the matrix without looking at the cached state
  24785. * @returns the view matrix
  24786. */
  24787. getViewMatrix(force?: boolean): Matrix;
  24788. /**
  24789. * Freeze the projection matrix.
  24790. * It will prevent the cache check of the camera projection compute and can speed up perf
  24791. * if no parameter of the camera are meant to change
  24792. * @param projection Defines manually a projection if necessary
  24793. */
  24794. freezeProjectionMatrix(projection?: Matrix): void;
  24795. /**
  24796. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24797. */
  24798. unfreezeProjectionMatrix(): void;
  24799. /**
  24800. * Gets the current projection matrix of the camera.
  24801. * @param force forces the camera to recompute the matrix without looking at the cached state
  24802. * @returns the projection matrix
  24803. */
  24804. getProjectionMatrix(force?: boolean): Matrix;
  24805. /**
  24806. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24807. * @returns a Matrix
  24808. */
  24809. getTransformationMatrix(): Matrix;
  24810. private _updateFrustumPlanes;
  24811. /**
  24812. * Checks if a cullable object (mesh...) is in the camera frustum
  24813. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24814. * @param target The object to check
  24815. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24816. * @returns true if the object is in frustum otherwise false
  24817. */
  24818. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24819. /**
  24820. * Checks if a cullable object (mesh...) is in the camera frustum
  24821. * Unlike isInFrustum this cheks the full bounding box
  24822. * @param target The object to check
  24823. * @returns true if the object is in frustum otherwise false
  24824. */
  24825. isCompletelyInFrustum(target: ICullable): boolean;
  24826. /**
  24827. * Gets a ray in the forward direction from the camera.
  24828. * @param length Defines the length of the ray to create
  24829. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24830. * @param origin Defines the start point of the ray which defaults to the camera position
  24831. * @returns the forward ray
  24832. */
  24833. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24834. /**
  24835. * Releases resources associated with this node.
  24836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24838. */
  24839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24840. /** @hidden */
  24841. _isLeftCamera: boolean;
  24842. /**
  24843. * Gets the left camera of a rig setup in case of Rigged Camera
  24844. */
  24845. readonly isLeftCamera: boolean;
  24846. /** @hidden */
  24847. _isRightCamera: boolean;
  24848. /**
  24849. * Gets the right camera of a rig setup in case of Rigged Camera
  24850. */
  24851. readonly isRightCamera: boolean;
  24852. /**
  24853. * Gets the left camera of a rig setup in case of Rigged Camera
  24854. */
  24855. readonly leftCamera: Nullable<FreeCamera>;
  24856. /**
  24857. * Gets the right camera of a rig setup in case of Rigged Camera
  24858. */
  24859. readonly rightCamera: Nullable<FreeCamera>;
  24860. /**
  24861. * Gets the left camera target of a rig setup in case of Rigged Camera
  24862. * @returns the target position
  24863. */
  24864. getLeftTarget(): Nullable<Vector3>;
  24865. /**
  24866. * Gets the right camera target of a rig setup in case of Rigged Camera
  24867. * @returns the target position
  24868. */
  24869. getRightTarget(): Nullable<Vector3>;
  24870. /**
  24871. * @hidden
  24872. */
  24873. setCameraRigMode(mode: number, rigParams: any): void;
  24874. /** @hidden */
  24875. static _setStereoscopicRigMode(camera: Camera): void;
  24876. /** @hidden */
  24877. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24878. /** @hidden */
  24879. static _setVRRigMode(camera: Camera, rigParams: any): void;
  24880. /** @hidden */
  24881. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24882. /** @hidden */
  24883. _getVRProjectionMatrix(): Matrix;
  24884. protected _updateCameraRotationMatrix(): void;
  24885. protected _updateWebVRCameraRotationMatrix(): void;
  24886. /**
  24887. * This function MUST be overwritten by the different WebVR cameras available.
  24888. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24889. * @hidden
  24890. */
  24891. _getWebVRProjectionMatrix(): Matrix;
  24892. /**
  24893. * This function MUST be overwritten by the different WebVR cameras available.
  24894. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24895. * @hidden
  24896. */
  24897. _getWebVRViewMatrix(): Matrix;
  24898. /** @hidden */
  24899. setCameraRigParameter(name: string, value: any): void;
  24900. /**
  24901. * needs to be overridden by children so sub has required properties to be copied
  24902. * @hidden
  24903. */
  24904. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24905. /**
  24906. * May need to be overridden by children
  24907. * @hidden
  24908. */
  24909. _updateRigCameras(): void;
  24910. /** @hidden */
  24911. _setupInputs(): void;
  24912. /**
  24913. * Serialiaze the camera setup to a json represention
  24914. * @returns the JSON representation
  24915. */
  24916. serialize(): any;
  24917. /**
  24918. * Clones the current camera.
  24919. * @param name The cloned camera name
  24920. * @returns the cloned camera
  24921. */
  24922. clone(name: string): Camera;
  24923. /**
  24924. * Gets the direction of the camera relative to a given local axis.
  24925. * @param localAxis Defines the reference axis to provide a relative direction.
  24926. * @return the direction
  24927. */
  24928. getDirection(localAxis: Vector3): Vector3;
  24929. /**
  24930. * Returns the current camera absolute rotation
  24931. */
  24932. readonly absoluteRotation: Quaternion;
  24933. /**
  24934. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24935. * @param localAxis Defines the reference axis to provide a relative direction.
  24936. * @param result Defines the vector to store the result in
  24937. */
  24938. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24939. /**
  24940. * Gets a camera constructor for a given camera type
  24941. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24942. * @param name The name of the camera the result will be able to instantiate
  24943. * @param scene The scene the result will construct the camera in
  24944. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24945. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24946. * @returns a factory method to construc the camera
  24947. */
  24948. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24949. /**
  24950. * Compute the world matrix of the camera.
  24951. * @returns the camera workd matrix
  24952. */
  24953. computeWorldMatrix(): Matrix;
  24954. /**
  24955. * Parse a JSON and creates the camera from the parsed information
  24956. * @param parsedCamera The JSON to parse
  24957. * @param scene The scene to instantiate the camera in
  24958. * @returns the newly constructed camera
  24959. */
  24960. static Parse(parsedCamera: any, scene: Scene): Camera;
  24961. }
  24962. }
  24963. declare module BABYLON {
  24964. /**
  24965. * Class containing static functions to help procedurally build meshes
  24966. */
  24967. export class DiscBuilder {
  24968. /**
  24969. * Creates a plane polygonal mesh. By default, this is a disc
  24970. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24971. * * 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
  24972. * * 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
  24973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24974. * * 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
  24975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24976. * @param name defines the name of the mesh
  24977. * @param options defines the options used to create the mesh
  24978. * @param scene defines the hosting scene
  24979. * @returns the plane polygonal mesh
  24980. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24981. */
  24982. static CreateDisc(name: string, options: {
  24983. radius?: number;
  24984. tessellation?: number;
  24985. arc?: number;
  24986. updatable?: boolean;
  24987. sideOrientation?: number;
  24988. frontUVs?: Vector4;
  24989. backUVs?: Vector4;
  24990. }, scene?: Nullable<Scene>): Mesh;
  24991. }
  24992. }
  24993. declare module BABYLON {
  24994. /**
  24995. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24996. *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.
  24997. * The SPS is also a particle system. It provides some methods to manage the particles.
  24998. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24999. *
  25000. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25001. */
  25002. export class SolidParticleSystem implements IDisposable {
  25003. /**
  25004. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25005. * Example : var p = SPS.particles[i];
  25006. */
  25007. particles: SolidParticle[];
  25008. /**
  25009. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25010. */
  25011. nbParticles: number;
  25012. /**
  25013. * If the particles must ever face the camera (default false). Useful for planar particles.
  25014. */
  25015. billboard: boolean;
  25016. /**
  25017. * Recompute normals when adding a shape
  25018. */
  25019. recomputeNormals: boolean;
  25020. /**
  25021. * This a counter ofr your own usage. It's not set by any SPS functions.
  25022. */
  25023. counter: number;
  25024. /**
  25025. * The SPS name. This name is also given to the underlying mesh.
  25026. */
  25027. name: string;
  25028. /**
  25029. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25030. */
  25031. mesh: Mesh;
  25032. /**
  25033. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25034. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25035. */
  25036. vars: any;
  25037. /**
  25038. * This array is populated when the SPS is set as 'pickable'.
  25039. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25040. * Each element of this array is an object `{idx: int, faceId: int}`.
  25041. * `idx` is the picked particle index in the `SPS.particles` array
  25042. * `faceId` is the picked face index counted within this particle.
  25043. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25044. */
  25045. pickedParticles: {
  25046. idx: number;
  25047. faceId: number;
  25048. }[];
  25049. /**
  25050. * This array is populated when `enableDepthSort` is set to true.
  25051. * Each element of this array is an instance of the class DepthSortedParticle.
  25052. */
  25053. depthSortedParticles: DepthSortedParticle[];
  25054. /**
  25055. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25056. * @hidden
  25057. */
  25058. _bSphereOnly: boolean;
  25059. /**
  25060. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25061. * @hidden
  25062. */
  25063. _bSphereRadiusFactor: number;
  25064. private _scene;
  25065. private _positions;
  25066. private _indices;
  25067. private _normals;
  25068. private _colors;
  25069. private _uvs;
  25070. private _indices32;
  25071. private _positions32;
  25072. private _normals32;
  25073. private _fixedNormal32;
  25074. private _colors32;
  25075. private _uvs32;
  25076. private _index;
  25077. private _updatable;
  25078. private _pickable;
  25079. private _isVisibilityBoxLocked;
  25080. private _alwaysVisible;
  25081. private _depthSort;
  25082. private _shapeCounter;
  25083. private _copy;
  25084. private _color;
  25085. private _computeParticleColor;
  25086. private _computeParticleTexture;
  25087. private _computeParticleRotation;
  25088. private _computeParticleVertex;
  25089. private _computeBoundingBox;
  25090. private _depthSortParticles;
  25091. private _camera;
  25092. private _mustUnrotateFixedNormals;
  25093. private _particlesIntersect;
  25094. private _needs32Bits;
  25095. /**
  25096. * Creates a SPS (Solid Particle System) object.
  25097. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25098. * @param scene (Scene) is the scene in which the SPS is added.
  25099. * @param options defines the options of the sps e.g.
  25100. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25101. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25102. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25103. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25104. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25105. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25106. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25107. */
  25108. constructor(name: string, scene: Scene, options?: {
  25109. updatable?: boolean;
  25110. isPickable?: boolean;
  25111. enableDepthSort?: boolean;
  25112. particleIntersection?: boolean;
  25113. boundingSphereOnly?: boolean;
  25114. bSphereRadiusFactor?: number;
  25115. });
  25116. /**
  25117. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25118. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25119. * @returns the created mesh
  25120. */
  25121. buildMesh(): Mesh;
  25122. /**
  25123. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25124. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25125. * Thus the particles generated from `digest()` have their property `position` set yet.
  25126. * @param mesh ( Mesh ) is the mesh to be digested
  25127. * @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
  25128. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25129. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25130. * @returns the current SPS
  25131. */
  25132. digest(mesh: Mesh, options?: {
  25133. facetNb?: number;
  25134. number?: number;
  25135. delta?: number;
  25136. }): SolidParticleSystem;
  25137. private _unrotateFixedNormals;
  25138. private _resetCopy;
  25139. private _meshBuilder;
  25140. private _posToShape;
  25141. private _uvsToShapeUV;
  25142. private _addParticle;
  25143. /**
  25144. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25145. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25146. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25147. * @param nb (positive integer) the number of particles to be created from this model
  25148. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25149. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25150. * @returns the number of shapes in the system
  25151. */
  25152. addShape(mesh: Mesh, nb: number, options?: {
  25153. positionFunction?: any;
  25154. vertexFunction?: any;
  25155. }): number;
  25156. private _rebuildParticle;
  25157. /**
  25158. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25159. * @returns the SPS.
  25160. */
  25161. rebuildMesh(): SolidParticleSystem;
  25162. /**
  25163. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25164. * This method calls `updateParticle()` for each particle of the SPS.
  25165. * For an animated SPS, it is usually called within the render loop.
  25166. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25167. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25168. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25169. * @returns the SPS.
  25170. */
  25171. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25172. /**
  25173. * Disposes the SPS.
  25174. */
  25175. dispose(): void;
  25176. /**
  25177. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25178. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25179. * @returns the SPS.
  25180. */
  25181. refreshVisibleSize(): SolidParticleSystem;
  25182. /**
  25183. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25184. * @param size the size (float) of the visibility box
  25185. * note : this doesn't lock the SPS mesh bounding box.
  25186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25187. */
  25188. setVisibilityBox(size: number): void;
  25189. /**
  25190. * Gets whether the SPS as always visible or not
  25191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25192. */
  25193. /**
  25194. * Sets the SPS as always visible or not
  25195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25196. */
  25197. isAlwaysVisible: boolean;
  25198. /**
  25199. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25201. */
  25202. /**
  25203. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25205. */
  25206. isVisibilityBoxLocked: boolean;
  25207. /**
  25208. * Tells to `setParticles()` to compute the particle rotations or not.
  25209. * Default value : true. The SPS is faster when it's set to false.
  25210. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25211. */
  25212. /**
  25213. * Gets if `setParticles()` computes the particle rotations or not.
  25214. * Default value : true. The SPS is faster when it's set to false.
  25215. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25216. */
  25217. computeParticleRotation: boolean;
  25218. /**
  25219. * Tells to `setParticles()` to compute the particle colors or not.
  25220. * Default value : true. The SPS is faster when it's set to false.
  25221. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25222. */
  25223. /**
  25224. * Gets if `setParticles()` computes the particle colors or not.
  25225. * Default value : true. The SPS is faster when it's set to false.
  25226. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25227. */
  25228. computeParticleColor: boolean;
  25229. /**
  25230. * Gets if `setParticles()` computes the particle textures or not.
  25231. * Default value : true. The SPS is faster when it's set to false.
  25232. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25233. */
  25234. computeParticleTexture: boolean;
  25235. /**
  25236. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25237. * Default value : false. The SPS is faster when it's set to false.
  25238. * Note : the particle custom vertex positions aren't stored values.
  25239. */
  25240. /**
  25241. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25242. * Default value : false. The SPS is faster when it's set to false.
  25243. * Note : the particle custom vertex positions aren't stored values.
  25244. */
  25245. computeParticleVertex: boolean;
  25246. /**
  25247. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25248. */
  25249. /**
  25250. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25251. */
  25252. computeBoundingBox: boolean;
  25253. /**
  25254. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25255. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25256. * Default : `true`
  25257. */
  25258. /**
  25259. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25260. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25261. * Default : `true`
  25262. */
  25263. depthSortParticles: boolean;
  25264. /**
  25265. * This function does nothing. It may be overwritten to set all the particle first values.
  25266. * The SPS doesn't call this function, you may have to call it by your own.
  25267. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25268. */
  25269. initParticles(): void;
  25270. /**
  25271. * This function does nothing. It may be overwritten to recycle a particle.
  25272. * The SPS doesn't call this function, you may have to call it by your own.
  25273. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25274. * @param particle The particle to recycle
  25275. * @returns the recycled particle
  25276. */
  25277. recycleParticle(particle: SolidParticle): SolidParticle;
  25278. /**
  25279. * Updates a particle : this function should be overwritten by the user.
  25280. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25281. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25282. * @example : just set a particle position or velocity and recycle conditions
  25283. * @param particle The particle to update
  25284. * @returns the updated particle
  25285. */
  25286. updateParticle(particle: SolidParticle): SolidParticle;
  25287. /**
  25288. * Updates a vertex of a particle : it can be overwritten by the user.
  25289. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25290. * @param particle the current particle
  25291. * @param vertex the current index of the current particle
  25292. * @param pt the index of the current vertex in the particle shape
  25293. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25294. * @example : just set a vertex particle position
  25295. * @returns the updated vertex
  25296. */
  25297. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25298. /**
  25299. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25300. * This does nothing and may be overwritten by the user.
  25301. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25302. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25303. * @param update the boolean update value actually passed to setParticles()
  25304. */
  25305. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25306. /**
  25307. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25308. * This will be passed three parameters.
  25309. * This does nothing and may be overwritten by the user.
  25310. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25311. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25312. * @param update the boolean update value actually passed to setParticles()
  25313. */
  25314. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25315. }
  25316. }
  25317. declare module BABYLON {
  25318. /**
  25319. * Represents one particle of a solid particle system.
  25320. */
  25321. export class SolidParticle {
  25322. /**
  25323. * particle global index
  25324. */
  25325. idx: number;
  25326. /**
  25327. * The color of the particle
  25328. */
  25329. color: Nullable<Color4>;
  25330. /**
  25331. * The world space position of the particle.
  25332. */
  25333. position: Vector3;
  25334. /**
  25335. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25336. */
  25337. rotation: Vector3;
  25338. /**
  25339. * The world space rotation quaternion of the particle.
  25340. */
  25341. rotationQuaternion: Nullable<Quaternion>;
  25342. /**
  25343. * The scaling of the particle.
  25344. */
  25345. scaling: Vector3;
  25346. /**
  25347. * The uvs of the particle.
  25348. */
  25349. uvs: Vector4;
  25350. /**
  25351. * The current speed of the particle.
  25352. */
  25353. velocity: Vector3;
  25354. /**
  25355. * The pivot point in the particle local space.
  25356. */
  25357. pivot: Vector3;
  25358. /**
  25359. * Must the particle be translated from its pivot point in its local space ?
  25360. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25361. * Default : false
  25362. */
  25363. translateFromPivot: boolean;
  25364. /**
  25365. * Is the particle active or not ?
  25366. */
  25367. alive: boolean;
  25368. /**
  25369. * Is the particle visible or not ?
  25370. */
  25371. isVisible: boolean;
  25372. /**
  25373. * Index of this particle in the global "positions" array (Internal use)
  25374. * @hidden
  25375. */
  25376. _pos: number;
  25377. /**
  25378. * @hidden Index of this particle in the global "indices" array (Internal use)
  25379. */
  25380. _ind: number;
  25381. /**
  25382. * @hidden ModelShape of this particle (Internal use)
  25383. */
  25384. _model: ModelShape;
  25385. /**
  25386. * ModelShape id of this particle
  25387. */
  25388. shapeId: number;
  25389. /**
  25390. * Index of the particle in its shape id
  25391. */
  25392. idxInShape: number;
  25393. /**
  25394. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25395. */
  25396. _modelBoundingInfo: BoundingInfo;
  25397. /**
  25398. * @hidden Particle BoundingInfo object (Internal use)
  25399. */
  25400. _boundingInfo: BoundingInfo;
  25401. /**
  25402. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25403. */
  25404. _sps: SolidParticleSystem;
  25405. /**
  25406. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25407. */
  25408. _stillInvisible: boolean;
  25409. /**
  25410. * @hidden Last computed particle rotation matrix
  25411. */
  25412. _rotationMatrix: number[];
  25413. /**
  25414. * Parent particle Id, if any.
  25415. * Default null.
  25416. */
  25417. parentId: Nullable<number>;
  25418. /**
  25419. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25420. * The possible values are :
  25421. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25422. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25423. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25424. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25425. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25426. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25427. * */
  25428. cullingStrategy: number;
  25429. /**
  25430. * @hidden Internal global position in the SPS.
  25431. */
  25432. _globalPosition: Vector3;
  25433. /**
  25434. * Creates a Solid Particle object.
  25435. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25436. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25437. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25438. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25439. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25440. * @param shapeId (integer) is the model shape identifier in the SPS.
  25441. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25442. * @param sps defines the sps it is associated to
  25443. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25444. */
  25445. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25446. /**
  25447. * Legacy support, changed scale to scaling
  25448. */
  25449. /**
  25450. * Legacy support, changed scale to scaling
  25451. */
  25452. scale: Vector3;
  25453. /**
  25454. * Legacy support, changed quaternion to rotationQuaternion
  25455. */
  25456. /**
  25457. * Legacy support, changed quaternion to rotationQuaternion
  25458. */
  25459. quaternion: Nullable<Quaternion>;
  25460. /**
  25461. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25462. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25463. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25464. * @returns true if it intersects
  25465. */
  25466. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25467. /**
  25468. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25469. * A particle is in the frustum if its bounding box intersects the frustum
  25470. * @param frustumPlanes defines the frustum to test
  25471. * @returns true if the particle is in the frustum planes
  25472. */
  25473. isInFrustum(frustumPlanes: Plane[]): boolean;
  25474. /**
  25475. * get the rotation matrix of the particle
  25476. * @hidden
  25477. */
  25478. getRotationMatrix(m: Matrix): void;
  25479. }
  25480. /**
  25481. * Represents the shape of the model used by one particle of a solid particle system.
  25482. * SPS internal tool, don't use it manually.
  25483. */
  25484. export class ModelShape {
  25485. /**
  25486. * The shape id
  25487. * @hidden
  25488. */
  25489. shapeID: number;
  25490. /**
  25491. * flat array of model positions (internal use)
  25492. * @hidden
  25493. */
  25494. _shape: Vector3[];
  25495. /**
  25496. * flat array of model UVs (internal use)
  25497. * @hidden
  25498. */
  25499. _shapeUV: number[];
  25500. /**
  25501. * length of the shape in the model indices array (internal use)
  25502. * @hidden
  25503. */
  25504. _indicesLength: number;
  25505. /**
  25506. * Custom position function (internal use)
  25507. * @hidden
  25508. */
  25509. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25510. /**
  25511. * Custom vertex function (internal use)
  25512. * @hidden
  25513. */
  25514. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25515. /**
  25516. * 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.
  25517. * SPS internal tool, don't use it manually.
  25518. * @hidden
  25519. */
  25520. 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>);
  25521. }
  25522. /**
  25523. * Represents a Depth Sorted Particle in the solid particle system.
  25524. */
  25525. export class DepthSortedParticle {
  25526. /**
  25527. * Index of the particle in the "indices" array
  25528. */
  25529. ind: number;
  25530. /**
  25531. * Length of the particle shape in the "indices" array
  25532. */
  25533. indicesLength: number;
  25534. /**
  25535. * Squared distance from the particle to the camera
  25536. */
  25537. sqDistance: number;
  25538. }
  25539. }
  25540. declare module BABYLON {
  25541. /**
  25542. * @hidden
  25543. */
  25544. export class _MeshCollisionData {
  25545. _checkCollisions: boolean;
  25546. _collisionMask: number;
  25547. _collisionGroup: number;
  25548. _collider: Nullable<Collider>;
  25549. _oldPositionForCollisions: Vector3;
  25550. _diffPositionForCollisions: Vector3;
  25551. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25552. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25553. }
  25554. }
  25555. declare module BABYLON {
  25556. /** @hidden */
  25557. class _FacetDataStorage {
  25558. facetPositions: Vector3[];
  25559. facetNormals: Vector3[];
  25560. facetPartitioning: number[][];
  25561. facetNb: number;
  25562. partitioningSubdivisions: number;
  25563. partitioningBBoxRatio: number;
  25564. facetDataEnabled: boolean;
  25565. facetParameters: any;
  25566. bbSize: Vector3;
  25567. subDiv: {
  25568. max: number;
  25569. X: number;
  25570. Y: number;
  25571. Z: number;
  25572. };
  25573. facetDepthSort: boolean;
  25574. facetDepthSortEnabled: boolean;
  25575. depthSortedIndices: IndicesArray;
  25576. depthSortedFacets: {
  25577. ind: number;
  25578. sqDistance: number;
  25579. }[];
  25580. facetDepthSortFunction: (f1: {
  25581. ind: number;
  25582. sqDistance: number;
  25583. }, f2: {
  25584. ind: number;
  25585. sqDistance: number;
  25586. }) => number;
  25587. facetDepthSortFrom: Vector3;
  25588. facetDepthSortOrigin: Vector3;
  25589. invertedMatrix: Matrix;
  25590. }
  25591. /**
  25592. * @hidden
  25593. **/
  25594. class _InternalAbstractMeshDataInfo {
  25595. _hasVertexAlpha: boolean;
  25596. _useVertexColors: boolean;
  25597. _numBoneInfluencers: number;
  25598. _applyFog: boolean;
  25599. _receiveShadows: boolean;
  25600. _facetData: _FacetDataStorage;
  25601. _visibility: number;
  25602. _skeleton: Nullable<Skeleton>;
  25603. _layerMask: number;
  25604. _computeBonesUsingShaders: boolean;
  25605. _isActive: boolean;
  25606. _onlyForInstances: boolean;
  25607. _isActiveIntermediate: boolean;
  25608. _onlyForInstancesIntermediate: boolean;
  25609. }
  25610. /**
  25611. * Class used to store all common mesh properties
  25612. */
  25613. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25614. /** No occlusion */
  25615. static OCCLUSION_TYPE_NONE: number;
  25616. /** Occlusion set to optimisitic */
  25617. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25618. /** Occlusion set to strict */
  25619. static OCCLUSION_TYPE_STRICT: number;
  25620. /** Use an accurante occlusion algorithm */
  25621. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25622. /** Use a conservative occlusion algorithm */
  25623. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25624. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25625. * Test order :
  25626. * Is the bounding sphere outside the frustum ?
  25627. * If not, are the bounding box vertices outside the frustum ?
  25628. * It not, then the cullable object is in the frustum.
  25629. */
  25630. static readonly CULLINGSTRATEGY_STANDARD: number;
  25631. /** Culling strategy : Bounding Sphere Only.
  25632. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25633. * It's also less accurate than the standard because some not visible objects can still be selected.
  25634. * Test : is the bounding sphere outside the frustum ?
  25635. * If not, then the cullable object is in the frustum.
  25636. */
  25637. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25638. /** Culling strategy : Optimistic Inclusion.
  25639. * This in an inclusion test first, then the standard exclusion test.
  25640. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25641. * 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.
  25642. * Anyway, it's as accurate as the standard strategy.
  25643. * Test :
  25644. * Is the cullable object bounding sphere center in the frustum ?
  25645. * If not, apply the default culling strategy.
  25646. */
  25647. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25648. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25649. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25650. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25651. * 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.
  25652. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25653. * Test :
  25654. * Is the cullable object bounding sphere center in the frustum ?
  25655. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25656. */
  25657. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25658. /**
  25659. * No billboard
  25660. */
  25661. static readonly BILLBOARDMODE_NONE: number;
  25662. /** Billboard on X axis */
  25663. static readonly BILLBOARDMODE_X: number;
  25664. /** Billboard on Y axis */
  25665. static readonly BILLBOARDMODE_Y: number;
  25666. /** Billboard on Z axis */
  25667. static readonly BILLBOARDMODE_Z: number;
  25668. /** Billboard on all axes */
  25669. static readonly BILLBOARDMODE_ALL: number;
  25670. /** Billboard on using position instead of orientation */
  25671. static readonly BILLBOARDMODE_USE_POSITION: number;
  25672. /** @hidden */
  25673. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25674. /**
  25675. * The culling strategy to use to check whether the mesh must be rendered or not.
  25676. * This value can be changed at any time and will be used on the next render mesh selection.
  25677. * The possible values are :
  25678. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25679. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25680. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25681. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25682. * Please read each static variable documentation to get details about the culling process.
  25683. * */
  25684. cullingStrategy: number;
  25685. /**
  25686. * Gets the number of facets in the mesh
  25687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25688. */
  25689. readonly facetNb: number;
  25690. /**
  25691. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25692. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25693. */
  25694. partitioningSubdivisions: number;
  25695. /**
  25696. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25697. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25699. */
  25700. partitioningBBoxRatio: number;
  25701. /**
  25702. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25703. * Works only for updatable meshes.
  25704. * Doesn't work with multi-materials
  25705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25706. */
  25707. mustDepthSortFacets: boolean;
  25708. /**
  25709. * The location (Vector3) where the facet depth sort must be computed from.
  25710. * By default, the active camera position.
  25711. * Used only when facet depth sort is enabled
  25712. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25713. */
  25714. facetDepthSortFrom: Vector3;
  25715. /**
  25716. * gets a boolean indicating if facetData is enabled
  25717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25718. */
  25719. readonly isFacetDataEnabled: boolean;
  25720. /** @hidden */
  25721. _updateNonUniformScalingState(value: boolean): boolean;
  25722. /**
  25723. * An event triggered when this mesh collides with another one
  25724. */
  25725. onCollideObservable: Observable<AbstractMesh>;
  25726. /** Set a function to call when this mesh collides with another one */
  25727. onCollide: () => void;
  25728. /**
  25729. * An event triggered when the collision's position changes
  25730. */
  25731. onCollisionPositionChangeObservable: Observable<Vector3>;
  25732. /** Set a function to call when the collision's position changes */
  25733. onCollisionPositionChange: () => void;
  25734. /**
  25735. * An event triggered when material is changed
  25736. */
  25737. onMaterialChangedObservable: Observable<AbstractMesh>;
  25738. /**
  25739. * Gets or sets the orientation for POV movement & rotation
  25740. */
  25741. definedFacingForward: boolean;
  25742. /** @hidden */
  25743. _occlusionQuery: Nullable<WebGLQuery>;
  25744. /** @hidden */
  25745. _renderingGroup: Nullable<RenderingGroup>;
  25746. /**
  25747. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25748. */
  25749. /**
  25750. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25751. */
  25752. visibility: number;
  25753. /** Gets or sets the alpha index used to sort transparent meshes
  25754. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25755. */
  25756. alphaIndex: number;
  25757. /**
  25758. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25759. */
  25760. isVisible: boolean;
  25761. /**
  25762. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25763. */
  25764. isPickable: boolean;
  25765. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25766. showSubMeshesBoundingBox: boolean;
  25767. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25768. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25769. */
  25770. isBlocker: boolean;
  25771. /**
  25772. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25773. */
  25774. enablePointerMoveEvents: boolean;
  25775. /**
  25776. * Specifies the rendering group id for this mesh (0 by default)
  25777. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25778. */
  25779. renderingGroupId: number;
  25780. private _material;
  25781. /** Gets or sets current material */
  25782. material: Nullable<Material>;
  25783. /**
  25784. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25785. * @see http://doc.babylonjs.com/babylon101/shadows
  25786. */
  25787. receiveShadows: boolean;
  25788. /** Defines color to use when rendering outline */
  25789. outlineColor: Color3;
  25790. /** Define width to use when rendering outline */
  25791. outlineWidth: number;
  25792. /** Defines color to use when rendering overlay */
  25793. overlayColor: Color3;
  25794. /** Defines alpha to use when rendering overlay */
  25795. overlayAlpha: number;
  25796. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25797. hasVertexAlpha: boolean;
  25798. /** 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) */
  25799. useVertexColors: boolean;
  25800. /**
  25801. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25802. */
  25803. computeBonesUsingShaders: boolean;
  25804. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25805. numBoneInfluencers: number;
  25806. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25807. applyFog: boolean;
  25808. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25809. useOctreeForRenderingSelection: boolean;
  25810. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25811. useOctreeForPicking: boolean;
  25812. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25813. useOctreeForCollisions: boolean;
  25814. /**
  25815. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25816. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25817. */
  25818. layerMask: number;
  25819. /**
  25820. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25821. */
  25822. alwaysSelectAsActiveMesh: boolean;
  25823. /**
  25824. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25825. */
  25826. doNotSyncBoundingInfo: boolean;
  25827. /**
  25828. * Gets or sets the current action manager
  25829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25830. */
  25831. actionManager: Nullable<AbstractActionManager>;
  25832. private _meshCollisionData;
  25833. /**
  25834. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25836. */
  25837. ellipsoid: Vector3;
  25838. /**
  25839. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25841. */
  25842. ellipsoidOffset: Vector3;
  25843. /**
  25844. * Gets or sets a collision mask used to mask collisions (default is -1).
  25845. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25846. */
  25847. collisionMask: number;
  25848. /**
  25849. * Gets or sets the current collision group mask (-1 by default).
  25850. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25851. */
  25852. collisionGroup: number;
  25853. /**
  25854. * Defines edge width used when edgesRenderer is enabled
  25855. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25856. */
  25857. edgesWidth: number;
  25858. /**
  25859. * Defines edge color used when edgesRenderer is enabled
  25860. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25861. */
  25862. edgesColor: Color4;
  25863. /** @hidden */
  25864. _edgesRenderer: Nullable<IEdgesRenderer>;
  25865. /** @hidden */
  25866. _masterMesh: Nullable<AbstractMesh>;
  25867. /** @hidden */
  25868. _boundingInfo: Nullable<BoundingInfo>;
  25869. /** @hidden */
  25870. _renderId: number;
  25871. /**
  25872. * Gets or sets the list of subMeshes
  25873. * @see http://doc.babylonjs.com/how_to/multi_materials
  25874. */
  25875. subMeshes: SubMesh[];
  25876. /** @hidden */
  25877. _intersectionsInProgress: AbstractMesh[];
  25878. /** @hidden */
  25879. _unIndexed: boolean;
  25880. /** @hidden */
  25881. _lightSources: Light[];
  25882. /** Gets the list of lights affecting that mesh */
  25883. readonly lightSources: Light[];
  25884. /** @hidden */
  25885. readonly _positions: Nullable<Vector3[]>;
  25886. /** @hidden */
  25887. _waitingData: {
  25888. lods: Nullable<any>;
  25889. actions: Nullable<any>;
  25890. freezeWorldMatrix: Nullable<boolean>;
  25891. };
  25892. /** @hidden */
  25893. _bonesTransformMatrices: Nullable<Float32Array>;
  25894. /** @hidden */
  25895. _transformMatrixTexture: Nullable<RawTexture>;
  25896. /**
  25897. * Gets or sets a skeleton to apply skining transformations
  25898. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25899. */
  25900. skeleton: Nullable<Skeleton>;
  25901. /**
  25902. * An event triggered when the mesh is rebuilt.
  25903. */
  25904. onRebuildObservable: Observable<AbstractMesh>;
  25905. /**
  25906. * Creates a new AbstractMesh
  25907. * @param name defines the name of the mesh
  25908. * @param scene defines the hosting scene
  25909. */
  25910. constructor(name: string, scene?: Nullable<Scene>);
  25911. /**
  25912. * Returns the string "AbstractMesh"
  25913. * @returns "AbstractMesh"
  25914. */
  25915. getClassName(): string;
  25916. /**
  25917. * Gets a string representation of the current mesh
  25918. * @param fullDetails defines a boolean indicating if full details must be included
  25919. * @returns a string representation of the current mesh
  25920. */
  25921. toString(fullDetails?: boolean): string;
  25922. /**
  25923. * @hidden
  25924. */
  25925. protected _getEffectiveParent(): Nullable<Node>;
  25926. /** @hidden */
  25927. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25928. /** @hidden */
  25929. _rebuild(): void;
  25930. /** @hidden */
  25931. _resyncLightSources(): void;
  25932. /** @hidden */
  25933. _resyncLighSource(light: Light): void;
  25934. /** @hidden */
  25935. _unBindEffect(): void;
  25936. /** @hidden */
  25937. _removeLightSource(light: Light, dispose: boolean): void;
  25938. private _markSubMeshesAsDirty;
  25939. /** @hidden */
  25940. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25941. /** @hidden */
  25942. _markSubMeshesAsAttributesDirty(): void;
  25943. /** @hidden */
  25944. _markSubMeshesAsMiscDirty(): void;
  25945. /**
  25946. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25947. */
  25948. scaling: Vector3;
  25949. /**
  25950. * Returns true if the mesh is blocked. Implemented by child classes
  25951. */
  25952. readonly isBlocked: boolean;
  25953. /**
  25954. * Returns the mesh itself by default. Implemented by child classes
  25955. * @param camera defines the camera to use to pick the right LOD level
  25956. * @returns the currentAbstractMesh
  25957. */
  25958. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25959. /**
  25960. * Returns 0 by default. Implemented by child classes
  25961. * @returns an integer
  25962. */
  25963. getTotalVertices(): number;
  25964. /**
  25965. * Returns a positive integer : the total number of indices in this mesh geometry.
  25966. * @returns the numner of indices or zero if the mesh has no geometry.
  25967. */
  25968. getTotalIndices(): number;
  25969. /**
  25970. * Returns null by default. Implemented by child classes
  25971. * @returns null
  25972. */
  25973. getIndices(): Nullable<IndicesArray>;
  25974. /**
  25975. * Returns the array of the requested vertex data kind. Implemented by child classes
  25976. * @param kind defines the vertex data kind to use
  25977. * @returns null
  25978. */
  25979. getVerticesData(kind: string): Nullable<FloatArray>;
  25980. /**
  25981. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25982. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25983. * Note that a new underlying VertexBuffer object is created each call.
  25984. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25985. * @param kind defines vertex data kind:
  25986. * * VertexBuffer.PositionKind
  25987. * * VertexBuffer.UVKind
  25988. * * VertexBuffer.UV2Kind
  25989. * * VertexBuffer.UV3Kind
  25990. * * VertexBuffer.UV4Kind
  25991. * * VertexBuffer.UV5Kind
  25992. * * VertexBuffer.UV6Kind
  25993. * * VertexBuffer.ColorKind
  25994. * * VertexBuffer.MatricesIndicesKind
  25995. * * VertexBuffer.MatricesIndicesExtraKind
  25996. * * VertexBuffer.MatricesWeightsKind
  25997. * * VertexBuffer.MatricesWeightsExtraKind
  25998. * @param data defines the data source
  25999. * @param updatable defines if the data must be flagged as updatable (or static)
  26000. * @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
  26001. * @returns the current mesh
  26002. */
  26003. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26004. /**
  26005. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26006. * If the mesh has no geometry, it is simply returned as it is.
  26007. * @param kind defines vertex data kind:
  26008. * * VertexBuffer.PositionKind
  26009. * * VertexBuffer.UVKind
  26010. * * VertexBuffer.UV2Kind
  26011. * * VertexBuffer.UV3Kind
  26012. * * VertexBuffer.UV4Kind
  26013. * * VertexBuffer.UV5Kind
  26014. * * VertexBuffer.UV6Kind
  26015. * * VertexBuffer.ColorKind
  26016. * * VertexBuffer.MatricesIndicesKind
  26017. * * VertexBuffer.MatricesIndicesExtraKind
  26018. * * VertexBuffer.MatricesWeightsKind
  26019. * * VertexBuffer.MatricesWeightsExtraKind
  26020. * @param data defines the data source
  26021. * @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
  26022. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26023. * @returns the current mesh
  26024. */
  26025. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26026. /**
  26027. * Sets the mesh indices,
  26028. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26029. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26030. * @param totalVertices Defines the total number of vertices
  26031. * @returns the current mesh
  26032. */
  26033. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26034. /**
  26035. * Gets a boolean indicating if specific vertex data is present
  26036. * @param kind defines the vertex data kind to use
  26037. * @returns true is data kind is present
  26038. */
  26039. isVerticesDataPresent(kind: string): boolean;
  26040. /**
  26041. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26042. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26043. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26044. * @returns a BoundingInfo
  26045. */
  26046. getBoundingInfo(): BoundingInfo;
  26047. /**
  26048. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26049. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26050. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26051. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26052. * @returns the current mesh
  26053. */
  26054. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26055. /**
  26056. * Overwrite the current bounding info
  26057. * @param boundingInfo defines the new bounding info
  26058. * @returns the current mesh
  26059. */
  26060. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26061. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26062. readonly useBones: boolean;
  26063. /** @hidden */
  26064. _preActivate(): void;
  26065. /** @hidden */
  26066. _preActivateForIntermediateRendering(renderId: number): void;
  26067. /** @hidden */
  26068. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26069. /** @hidden */
  26070. _postActivate(): void;
  26071. /** @hidden */
  26072. _freeze(): void;
  26073. /** @hidden */
  26074. _unFreeze(): void;
  26075. /**
  26076. * Gets the current world matrix
  26077. * @returns a Matrix
  26078. */
  26079. getWorldMatrix(): Matrix;
  26080. /** @hidden */
  26081. _getWorldMatrixDeterminant(): number;
  26082. /**
  26083. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26084. */
  26085. readonly isAnInstance: boolean;
  26086. /**
  26087. * Gets a boolean indicating if this mesh has instances
  26088. */
  26089. readonly hasInstances: boolean;
  26090. /**
  26091. * Perform relative position change from the point of view of behind the front of the mesh.
  26092. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26093. * Supports definition of mesh facing forward or backward
  26094. * @param amountRight defines the distance on the right axis
  26095. * @param amountUp defines the distance on the up axis
  26096. * @param amountForward defines the distance on the forward axis
  26097. * @returns the current mesh
  26098. */
  26099. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26100. /**
  26101. * Calculate relative position change from the point of view of behind the front of the mesh.
  26102. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26103. * Supports definition of mesh facing forward or backward
  26104. * @param amountRight defines the distance on the right axis
  26105. * @param amountUp defines the distance on the up axis
  26106. * @param amountForward defines the distance on the forward axis
  26107. * @returns the new displacement vector
  26108. */
  26109. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26110. /**
  26111. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26112. * Supports definition of mesh facing forward or backward
  26113. * @param flipBack defines the flip
  26114. * @param twirlClockwise defines the twirl
  26115. * @param tiltRight defines the tilt
  26116. * @returns the current mesh
  26117. */
  26118. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26119. /**
  26120. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26121. * Supports definition of mesh facing forward or backward.
  26122. * @param flipBack defines the flip
  26123. * @param twirlClockwise defines the twirl
  26124. * @param tiltRight defines the tilt
  26125. * @returns the new rotation vector
  26126. */
  26127. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26128. /**
  26129. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26130. * This means the mesh underlying bounding box and sphere are recomputed.
  26131. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26132. * @returns the current mesh
  26133. */
  26134. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26135. /** @hidden */
  26136. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26137. /** @hidden */
  26138. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26139. /** @hidden */
  26140. _updateBoundingInfo(): AbstractMesh;
  26141. /** @hidden */
  26142. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26143. /** @hidden */
  26144. protected _afterComputeWorldMatrix(): void;
  26145. /** @hidden */
  26146. readonly _effectiveMesh: AbstractMesh;
  26147. /**
  26148. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26149. * A mesh is in the frustum if its bounding box intersects the frustum
  26150. * @param frustumPlanes defines the frustum to test
  26151. * @returns true if the mesh is in the frustum planes
  26152. */
  26153. isInFrustum(frustumPlanes: Plane[]): boolean;
  26154. /**
  26155. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26156. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26157. * @param frustumPlanes defines the frustum to test
  26158. * @returns true if the mesh is completely in the frustum planes
  26159. */
  26160. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26161. /**
  26162. * True if the mesh intersects another mesh or a SolidParticle object
  26163. * @param mesh defines a target mesh or SolidParticle to test
  26164. * @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)
  26165. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26166. * @returns true if there is an intersection
  26167. */
  26168. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26169. /**
  26170. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26171. * @param point defines the point to test
  26172. * @returns true if there is an intersection
  26173. */
  26174. intersectsPoint(point: Vector3): boolean;
  26175. /**
  26176. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26177. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26178. */
  26179. checkCollisions: boolean;
  26180. /**
  26181. * Gets Collider object used to compute collisions (not physics)
  26182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26183. */
  26184. readonly collider: Nullable<Collider>;
  26185. /**
  26186. * Move the mesh using collision engine
  26187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26188. * @param displacement defines the requested displacement vector
  26189. * @returns the current mesh
  26190. */
  26191. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26192. private _onCollisionPositionChange;
  26193. /** @hidden */
  26194. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26195. /** @hidden */
  26196. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26197. /** @hidden */
  26198. _checkCollision(collider: Collider): AbstractMesh;
  26199. /** @hidden */
  26200. _generatePointsArray(): boolean;
  26201. /**
  26202. * Checks if the passed Ray intersects with the mesh
  26203. * @param ray defines the ray to use
  26204. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26205. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26206. * @returns the picking info
  26207. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26208. */
  26209. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26210. /**
  26211. * Clones the current mesh
  26212. * @param name defines the mesh name
  26213. * @param newParent defines the new mesh parent
  26214. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26215. * @returns the new mesh
  26216. */
  26217. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26218. /**
  26219. * Disposes all the submeshes of the current meshnp
  26220. * @returns the current mesh
  26221. */
  26222. releaseSubMeshes(): AbstractMesh;
  26223. /**
  26224. * Releases resources associated with this abstract mesh.
  26225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26227. */
  26228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26229. /**
  26230. * Adds the passed mesh as a child to the current mesh
  26231. * @param mesh defines the child mesh
  26232. * @returns the current mesh
  26233. */
  26234. addChild(mesh: AbstractMesh): AbstractMesh;
  26235. /**
  26236. * Removes the passed mesh from the current mesh children list
  26237. * @param mesh defines the child mesh
  26238. * @returns the current mesh
  26239. */
  26240. removeChild(mesh: AbstractMesh): AbstractMesh;
  26241. /** @hidden */
  26242. private _initFacetData;
  26243. /**
  26244. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26245. * This method can be called within the render loop.
  26246. * 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
  26247. * @returns the current mesh
  26248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26249. */
  26250. updateFacetData(): AbstractMesh;
  26251. /**
  26252. * Returns the facetLocalNormals array.
  26253. * The normals are expressed in the mesh local spac
  26254. * @returns an array of Vector3
  26255. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26256. */
  26257. getFacetLocalNormals(): Vector3[];
  26258. /**
  26259. * Returns the facetLocalPositions array.
  26260. * The facet positions are expressed in the mesh local space
  26261. * @returns an array of Vector3
  26262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26263. */
  26264. getFacetLocalPositions(): Vector3[];
  26265. /**
  26266. * Returns the facetLocalPartioning array
  26267. * @returns an array of array of numbers
  26268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26269. */
  26270. getFacetLocalPartitioning(): number[][];
  26271. /**
  26272. * Returns the i-th facet position in the world system.
  26273. * This method allocates a new Vector3 per call
  26274. * @param i defines the facet index
  26275. * @returns a new Vector3
  26276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26277. */
  26278. getFacetPosition(i: number): Vector3;
  26279. /**
  26280. * Sets the reference Vector3 with the i-th facet position in the world system
  26281. * @param i defines the facet index
  26282. * @param ref defines the target vector
  26283. * @returns the current mesh
  26284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26285. */
  26286. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26287. /**
  26288. * Returns the i-th facet normal in the world system.
  26289. * This method allocates a new Vector3 per call
  26290. * @param i defines the facet index
  26291. * @returns a new Vector3
  26292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26293. */
  26294. getFacetNormal(i: number): Vector3;
  26295. /**
  26296. * Sets the reference Vector3 with the i-th facet normal in the world system
  26297. * @param i defines the facet index
  26298. * @param ref defines the target vector
  26299. * @returns the current mesh
  26300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26301. */
  26302. getFacetNormalToRef(i: number, ref: Vector3): this;
  26303. /**
  26304. * 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)
  26305. * @param x defines x coordinate
  26306. * @param y defines y coordinate
  26307. * @param z defines z coordinate
  26308. * @returns the array of facet indexes
  26309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26310. */
  26311. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26312. /**
  26313. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26314. * @param projected sets as the (x,y,z) world projection on the facet
  26315. * @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
  26316. * @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
  26317. * @param x defines x coordinate
  26318. * @param y defines y coordinate
  26319. * @param z defines z coordinate
  26320. * @returns the face index if found (or null instead)
  26321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26322. */
  26323. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26324. /**
  26325. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26326. * @param projected sets as the (x,y,z) local projection on the facet
  26327. * @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
  26328. * @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
  26329. * @param x defines x coordinate
  26330. * @param y defines y coordinate
  26331. * @param z defines z coordinate
  26332. * @returns the face index if found (or null instead)
  26333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26334. */
  26335. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26336. /**
  26337. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26338. * @returns the parameters
  26339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26340. */
  26341. getFacetDataParameters(): any;
  26342. /**
  26343. * Disables the feature FacetData and frees the related memory
  26344. * @returns the current mesh
  26345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26346. */
  26347. disableFacetData(): AbstractMesh;
  26348. /**
  26349. * Updates the AbstractMesh indices array
  26350. * @param indices defines the data source
  26351. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26352. * @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)
  26353. * @returns the current mesh
  26354. */
  26355. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26356. /**
  26357. * Creates new normals data for the mesh
  26358. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26359. * @returns the current mesh
  26360. */
  26361. createNormals(updatable: boolean): AbstractMesh;
  26362. /**
  26363. * Align the mesh with a normal
  26364. * @param normal defines the normal to use
  26365. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26366. * @returns the current mesh
  26367. */
  26368. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26369. /** @hidden */
  26370. _checkOcclusionQuery(): boolean;
  26371. /**
  26372. * Disables the mesh edge rendering mode
  26373. * @returns the currentAbstractMesh
  26374. */
  26375. disableEdgesRendering(): AbstractMesh;
  26376. /**
  26377. * Enables the edge rendering mode on the mesh.
  26378. * This mode makes the mesh edges visible
  26379. * @param epsilon defines the maximal distance between two angles to detect a face
  26380. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26381. * @returns the currentAbstractMesh
  26382. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26383. */
  26384. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26385. }
  26386. }
  26387. declare module BABYLON {
  26388. /**
  26389. * Interface used to define ActionEvent
  26390. */
  26391. export interface IActionEvent {
  26392. /** The mesh or sprite that triggered the action */
  26393. source: any;
  26394. /** The X mouse cursor position at the time of the event */
  26395. pointerX: number;
  26396. /** The Y mouse cursor position at the time of the event */
  26397. pointerY: number;
  26398. /** The mesh that is currently pointed at (can be null) */
  26399. meshUnderPointer: Nullable<AbstractMesh>;
  26400. /** the original (browser) event that triggered the ActionEvent */
  26401. sourceEvent?: any;
  26402. /** additional data for the event */
  26403. additionalData?: any;
  26404. }
  26405. /**
  26406. * ActionEvent is the event being sent when an action is triggered.
  26407. */
  26408. export class ActionEvent implements IActionEvent {
  26409. /** The mesh or sprite that triggered the action */
  26410. source: any;
  26411. /** The X mouse cursor position at the time of the event */
  26412. pointerX: number;
  26413. /** The Y mouse cursor position at the time of the event */
  26414. pointerY: number;
  26415. /** The mesh that is currently pointed at (can be null) */
  26416. meshUnderPointer: Nullable<AbstractMesh>;
  26417. /** the original (browser) event that triggered the ActionEvent */
  26418. sourceEvent?: any;
  26419. /** additional data for the event */
  26420. additionalData?: any;
  26421. /**
  26422. * Creates a new ActionEvent
  26423. * @param source The mesh or sprite that triggered the action
  26424. * @param pointerX The X mouse cursor position at the time of the event
  26425. * @param pointerY The Y mouse cursor position at the time of the event
  26426. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26427. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26428. * @param additionalData additional data for the event
  26429. */
  26430. constructor(
  26431. /** The mesh or sprite that triggered the action */
  26432. source: any,
  26433. /** The X mouse cursor position at the time of the event */
  26434. pointerX: number,
  26435. /** The Y mouse cursor position at the time of the event */
  26436. pointerY: number,
  26437. /** The mesh that is currently pointed at (can be null) */
  26438. meshUnderPointer: Nullable<AbstractMesh>,
  26439. /** the original (browser) event that triggered the ActionEvent */
  26440. sourceEvent?: any,
  26441. /** additional data for the event */
  26442. additionalData?: any);
  26443. /**
  26444. * Helper function to auto-create an ActionEvent from a source mesh.
  26445. * @param source The source mesh that triggered the event
  26446. * @param evt The original (browser) event
  26447. * @param additionalData additional data for the event
  26448. * @returns the new ActionEvent
  26449. */
  26450. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26451. /**
  26452. * Helper function to auto-create an ActionEvent from a source sprite
  26453. * @param source The source sprite that triggered the event
  26454. * @param scene Scene associated with the sprite
  26455. * @param evt The original (browser) event
  26456. * @param additionalData additional data for the event
  26457. * @returns the new ActionEvent
  26458. */
  26459. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26460. /**
  26461. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26462. * @param scene the scene where the event occurred
  26463. * @param evt The original (browser) event
  26464. * @returns the new ActionEvent
  26465. */
  26466. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26467. /**
  26468. * Helper function to auto-create an ActionEvent from a primitive
  26469. * @param prim defines the target primitive
  26470. * @param pointerPos defines the pointer position
  26471. * @param evt The original (browser) event
  26472. * @param additionalData additional data for the event
  26473. * @returns the new ActionEvent
  26474. */
  26475. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26476. }
  26477. }
  26478. declare module BABYLON {
  26479. /**
  26480. * Abstract class used to decouple action Manager from scene and meshes.
  26481. * Do not instantiate.
  26482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26483. */
  26484. export abstract class AbstractActionManager implements IDisposable {
  26485. /** Gets the list of active triggers */
  26486. static Triggers: {
  26487. [key: string]: number;
  26488. };
  26489. /** Gets the cursor to use when hovering items */
  26490. hoverCursor: string;
  26491. /** Gets the list of actions */
  26492. actions: IAction[];
  26493. /**
  26494. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26495. */
  26496. isRecursive: boolean;
  26497. /**
  26498. * Releases all associated resources
  26499. */
  26500. abstract dispose(): void;
  26501. /**
  26502. * Does this action manager has pointer triggers
  26503. */
  26504. abstract readonly hasPointerTriggers: boolean;
  26505. /**
  26506. * Does this action manager has pick triggers
  26507. */
  26508. abstract readonly hasPickTriggers: boolean;
  26509. /**
  26510. * Process a specific trigger
  26511. * @param trigger defines the trigger to process
  26512. * @param evt defines the event details to be processed
  26513. */
  26514. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26515. /**
  26516. * Does this action manager handles actions of any of the given triggers
  26517. * @param triggers defines the triggers to be tested
  26518. * @return a boolean indicating whether one (or more) of the triggers is handled
  26519. */
  26520. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26521. /**
  26522. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26523. * speed.
  26524. * @param triggerA defines the trigger to be tested
  26525. * @param triggerB defines the trigger to be tested
  26526. * @return a boolean indicating whether one (or more) of the triggers is handled
  26527. */
  26528. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26529. /**
  26530. * Does this action manager handles actions of a given trigger
  26531. * @param trigger defines the trigger to be tested
  26532. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26533. * @return whether the trigger is handled
  26534. */
  26535. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26536. /**
  26537. * Serialize this manager to a JSON object
  26538. * @param name defines the property name to store this manager
  26539. * @returns a JSON representation of this manager
  26540. */
  26541. abstract serialize(name: string): any;
  26542. /**
  26543. * Registers an action to this action manager
  26544. * @param action defines the action to be registered
  26545. * @return the action amended (prepared) after registration
  26546. */
  26547. abstract registerAction(action: IAction): Nullable<IAction>;
  26548. /**
  26549. * Unregisters an action to this action manager
  26550. * @param action defines the action to be unregistered
  26551. * @return a boolean indicating whether the action has been unregistered
  26552. */
  26553. abstract unregisterAction(action: IAction): Boolean;
  26554. /**
  26555. * Does exist one action manager with at least one trigger
  26556. **/
  26557. static readonly HasTriggers: boolean;
  26558. /**
  26559. * Does exist one action manager with at least one pick trigger
  26560. **/
  26561. static readonly HasPickTriggers: boolean;
  26562. /**
  26563. * Does exist one action manager that handles actions of a given trigger
  26564. * @param trigger defines the trigger to be tested
  26565. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26566. **/
  26567. static HasSpecificTrigger(trigger: number): boolean;
  26568. }
  26569. }
  26570. declare module BABYLON {
  26571. /**
  26572. * Defines how a node can be built from a string name.
  26573. */
  26574. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26575. /**
  26576. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26577. */
  26578. export class Node implements IBehaviorAware<Node> {
  26579. /** @hidden */
  26580. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26581. private static _NodeConstructors;
  26582. /**
  26583. * Add a new node constructor
  26584. * @param type defines the type name of the node to construct
  26585. * @param constructorFunc defines the constructor function
  26586. */
  26587. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26588. /**
  26589. * Returns a node constructor based on type name
  26590. * @param type defines the type name
  26591. * @param name defines the new node name
  26592. * @param scene defines the hosting scene
  26593. * @param options defines optional options to transmit to constructors
  26594. * @returns the new constructor or null
  26595. */
  26596. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26597. /**
  26598. * Gets or sets the name of the node
  26599. */
  26600. name: string;
  26601. /**
  26602. * Gets or sets the id of the node
  26603. */
  26604. id: string;
  26605. /**
  26606. * Gets or sets the unique id of the node
  26607. */
  26608. uniqueId: number;
  26609. /**
  26610. * Gets or sets a string used to store user defined state for the node
  26611. */
  26612. state: string;
  26613. /**
  26614. * Gets or sets an object used to store user defined information for the node
  26615. */
  26616. metadata: any;
  26617. /**
  26618. * For internal use only. Please do not use.
  26619. */
  26620. reservedDataStore: any;
  26621. /**
  26622. * List of inspectable custom properties (used by the Inspector)
  26623. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26624. */
  26625. inspectableCustomProperties: IInspectable[];
  26626. /**
  26627. * Gets or sets a boolean used to define if the node must be serialized
  26628. */
  26629. doNotSerialize: boolean;
  26630. /** @hidden */
  26631. _isDisposed: boolean;
  26632. /**
  26633. * Gets a list of Animations associated with the node
  26634. */
  26635. animations: Animation[];
  26636. protected _ranges: {
  26637. [name: string]: Nullable<AnimationRange>;
  26638. };
  26639. /**
  26640. * Callback raised when the node is ready to be used
  26641. */
  26642. onReady: Nullable<(node: Node) => void>;
  26643. private _isEnabled;
  26644. private _isParentEnabled;
  26645. private _isReady;
  26646. /** @hidden */
  26647. _currentRenderId: number;
  26648. private _parentUpdateId;
  26649. /** @hidden */
  26650. _childUpdateId: number;
  26651. /** @hidden */
  26652. _waitingParentId: Nullable<string>;
  26653. /** @hidden */
  26654. _scene: Scene;
  26655. /** @hidden */
  26656. _cache: any;
  26657. private _parentNode;
  26658. private _children;
  26659. /** @hidden */
  26660. _worldMatrix: Matrix;
  26661. /** @hidden */
  26662. _worldMatrixDeterminant: number;
  26663. /** @hidden */
  26664. _worldMatrixDeterminantIsDirty: boolean;
  26665. /** @hidden */
  26666. private _sceneRootNodesIndex;
  26667. /**
  26668. * Gets a boolean indicating if the node has been disposed
  26669. * @returns true if the node was disposed
  26670. */
  26671. isDisposed(): boolean;
  26672. /**
  26673. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26674. * @see https://doc.babylonjs.com/how_to/parenting
  26675. */
  26676. parent: Nullable<Node>;
  26677. private addToSceneRootNodes;
  26678. private removeFromSceneRootNodes;
  26679. private _animationPropertiesOverride;
  26680. /**
  26681. * Gets or sets the animation properties override
  26682. */
  26683. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26684. /**
  26685. * Gets a string idenfifying the name of the class
  26686. * @returns "Node" string
  26687. */
  26688. getClassName(): string;
  26689. /** @hidden */
  26690. readonly _isNode: boolean;
  26691. /**
  26692. * An event triggered when the mesh is disposed
  26693. */
  26694. onDisposeObservable: Observable<Node>;
  26695. private _onDisposeObserver;
  26696. /**
  26697. * Sets a callback that will be raised when the node will be disposed
  26698. */
  26699. onDispose: () => void;
  26700. /**
  26701. * Creates a new Node
  26702. * @param name the name and id to be given to this node
  26703. * @param scene the scene this node will be added to
  26704. * @param addToRootNodes the node will be added to scene.rootNodes
  26705. */
  26706. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26707. /**
  26708. * Gets the scene of the node
  26709. * @returns a scene
  26710. */
  26711. getScene(): Scene;
  26712. /**
  26713. * Gets the engine of the node
  26714. * @returns a Engine
  26715. */
  26716. getEngine(): Engine;
  26717. private _behaviors;
  26718. /**
  26719. * Attach a behavior to the node
  26720. * @see http://doc.babylonjs.com/features/behaviour
  26721. * @param behavior defines the behavior to attach
  26722. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26723. * @returns the current Node
  26724. */
  26725. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26726. /**
  26727. * Remove an attached behavior
  26728. * @see http://doc.babylonjs.com/features/behaviour
  26729. * @param behavior defines the behavior to attach
  26730. * @returns the current Node
  26731. */
  26732. removeBehavior(behavior: Behavior<Node>): Node;
  26733. /**
  26734. * Gets the list of attached behaviors
  26735. * @see http://doc.babylonjs.com/features/behaviour
  26736. */
  26737. readonly behaviors: Behavior<Node>[];
  26738. /**
  26739. * Gets an attached behavior by name
  26740. * @param name defines the name of the behavior to look for
  26741. * @see http://doc.babylonjs.com/features/behaviour
  26742. * @returns null if behavior was not found else the requested behavior
  26743. */
  26744. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26745. /**
  26746. * Returns the latest update of the World matrix
  26747. * @returns a Matrix
  26748. */
  26749. getWorldMatrix(): Matrix;
  26750. /** @hidden */
  26751. _getWorldMatrixDeterminant(): number;
  26752. /**
  26753. * Returns directly the latest state of the mesh World matrix.
  26754. * A Matrix is returned.
  26755. */
  26756. readonly worldMatrixFromCache: Matrix;
  26757. /** @hidden */
  26758. _initCache(): void;
  26759. /** @hidden */
  26760. updateCache(force?: boolean): void;
  26761. /** @hidden */
  26762. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26763. /** @hidden */
  26764. _updateCache(ignoreParentClass?: boolean): void;
  26765. /** @hidden */
  26766. _isSynchronized(): boolean;
  26767. /** @hidden */
  26768. _markSyncedWithParent(): void;
  26769. /** @hidden */
  26770. isSynchronizedWithParent(): boolean;
  26771. /** @hidden */
  26772. isSynchronized(): boolean;
  26773. /**
  26774. * Is this node ready to be used/rendered
  26775. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26776. * @return true if the node is ready
  26777. */
  26778. isReady(completeCheck?: boolean): boolean;
  26779. /**
  26780. * Is this node enabled?
  26781. * 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
  26782. * @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
  26783. * @return whether this node (and its parent) is enabled
  26784. */
  26785. isEnabled(checkAncestors?: boolean): boolean;
  26786. /** @hidden */
  26787. protected _syncParentEnabledState(): void;
  26788. /**
  26789. * Set the enabled state of this node
  26790. * @param value defines the new enabled state
  26791. */
  26792. setEnabled(value: boolean): void;
  26793. /**
  26794. * Is this node a descendant of the given node?
  26795. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26796. * @param ancestor defines the parent node to inspect
  26797. * @returns a boolean indicating if this node is a descendant of the given node
  26798. */
  26799. isDescendantOf(ancestor: Node): boolean;
  26800. /** @hidden */
  26801. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26802. /**
  26803. * Will return all nodes that have this node as ascendant
  26804. * @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
  26805. * @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
  26806. * @return all children nodes of all types
  26807. */
  26808. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26809. /**
  26810. * Get all child-meshes of this node
  26811. * @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)
  26812. * @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
  26813. * @returns an array of AbstractMesh
  26814. */
  26815. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26816. /**
  26817. * Get all direct children of this node
  26818. * @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
  26819. * @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)
  26820. * @returns an array of Node
  26821. */
  26822. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26823. /** @hidden */
  26824. _setReady(state: boolean): void;
  26825. /**
  26826. * Get an animation by name
  26827. * @param name defines the name of the animation to look for
  26828. * @returns null if not found else the requested animation
  26829. */
  26830. getAnimationByName(name: string): Nullable<Animation>;
  26831. /**
  26832. * Creates an animation range for this node
  26833. * @param name defines the name of the range
  26834. * @param from defines the starting key
  26835. * @param to defines the end key
  26836. */
  26837. createAnimationRange(name: string, from: number, to: number): void;
  26838. /**
  26839. * Delete a specific animation range
  26840. * @param name defines the name of the range to delete
  26841. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26842. */
  26843. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26844. /**
  26845. * Get an animation range by name
  26846. * @param name defines the name of the animation range to look for
  26847. * @returns null if not found else the requested animation range
  26848. */
  26849. getAnimationRange(name: string): Nullable<AnimationRange>;
  26850. /**
  26851. * Gets the list of all animation ranges defined on this node
  26852. * @returns an array
  26853. */
  26854. getAnimationRanges(): Nullable<AnimationRange>[];
  26855. /**
  26856. * Will start the animation sequence
  26857. * @param name defines the range frames for animation sequence
  26858. * @param loop defines if the animation should loop (false by default)
  26859. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26860. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26861. * @returns the object created for this animation. If range does not exist, it will return null
  26862. */
  26863. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26864. /**
  26865. * Serialize animation ranges into a JSON compatible object
  26866. * @returns serialization object
  26867. */
  26868. serializeAnimationRanges(): any;
  26869. /**
  26870. * Computes the world matrix of the node
  26871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26872. * @returns the world matrix
  26873. */
  26874. computeWorldMatrix(force?: boolean): Matrix;
  26875. /**
  26876. * Releases resources associated with this node.
  26877. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26878. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26879. */
  26880. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26881. /**
  26882. * Parse animation range data from a serialization object and store them into a given node
  26883. * @param node defines where to store the animation ranges
  26884. * @param parsedNode defines the serialization object to read data from
  26885. * @param scene defines the hosting scene
  26886. */
  26887. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26888. /**
  26889. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26890. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26891. * @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
  26892. * @returns the new bounding vectors
  26893. */
  26894. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26895. min: Vector3;
  26896. max: Vector3;
  26897. };
  26898. }
  26899. }
  26900. declare module BABYLON {
  26901. /**
  26902. * @hidden
  26903. */
  26904. export class _IAnimationState {
  26905. key: number;
  26906. repeatCount: number;
  26907. workValue?: any;
  26908. loopMode?: number;
  26909. offsetValue?: any;
  26910. highLimitValue?: any;
  26911. }
  26912. /**
  26913. * Class used to store any kind of animation
  26914. */
  26915. export class Animation {
  26916. /**Name of the animation */
  26917. name: string;
  26918. /**Property to animate */
  26919. targetProperty: string;
  26920. /**The frames per second of the animation */
  26921. framePerSecond: number;
  26922. /**The data type of the animation */
  26923. dataType: number;
  26924. /**The loop mode of the animation */
  26925. loopMode?: number | undefined;
  26926. /**Specifies if blending should be enabled */
  26927. enableBlending?: boolean | undefined;
  26928. /**
  26929. * Use matrix interpolation instead of using direct key value when animating matrices
  26930. */
  26931. static AllowMatricesInterpolation: boolean;
  26932. /**
  26933. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26934. */
  26935. static AllowMatrixDecomposeForInterpolation: boolean;
  26936. /**
  26937. * Stores the key frames of the animation
  26938. */
  26939. private _keys;
  26940. /**
  26941. * Stores the easing function of the animation
  26942. */
  26943. private _easingFunction;
  26944. /**
  26945. * @hidden Internal use only
  26946. */
  26947. _runtimeAnimations: RuntimeAnimation[];
  26948. /**
  26949. * The set of event that will be linked to this animation
  26950. */
  26951. private _events;
  26952. /**
  26953. * Stores an array of target property paths
  26954. */
  26955. targetPropertyPath: string[];
  26956. /**
  26957. * Stores the blending speed of the animation
  26958. */
  26959. blendingSpeed: number;
  26960. /**
  26961. * Stores the animation ranges for the animation
  26962. */
  26963. private _ranges;
  26964. /**
  26965. * @hidden Internal use
  26966. */
  26967. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26968. /**
  26969. * Sets up an animation
  26970. * @param property The property to animate
  26971. * @param animationType The animation type to apply
  26972. * @param framePerSecond The frames per second of the animation
  26973. * @param easingFunction The easing function used in the animation
  26974. * @returns The created animation
  26975. */
  26976. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26977. /**
  26978. * Create and start an animation on a node
  26979. * @param name defines the name of the global animation that will be run on all nodes
  26980. * @param node defines the root node where the animation will take place
  26981. * @param targetProperty defines property to animate
  26982. * @param framePerSecond defines the number of frame per second yo use
  26983. * @param totalFrame defines the number of frames in total
  26984. * @param from defines the initial value
  26985. * @param to defines the final value
  26986. * @param loopMode defines which loop mode you want to use (off by default)
  26987. * @param easingFunction defines the easing function to use (linear by default)
  26988. * @param onAnimationEnd defines the callback to call when animation end
  26989. * @returns the animatable created for this animation
  26990. */
  26991. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26992. /**
  26993. * Create and start an animation on a node and its descendants
  26994. * @param name defines the name of the global animation that will be run on all nodes
  26995. * @param node defines the root node where the animation will take place
  26996. * @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
  26997. * @param targetProperty defines property to animate
  26998. * @param framePerSecond defines the number of frame per second to use
  26999. * @param totalFrame defines the number of frames in total
  27000. * @param from defines the initial value
  27001. * @param to defines the final value
  27002. * @param loopMode defines which loop mode you want to use (off by default)
  27003. * @param easingFunction defines the easing function to use (linear by default)
  27004. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27005. * @returns the list of animatables created for all nodes
  27006. * @example https://www.babylonjs-playground.com/#MH0VLI
  27007. */
  27008. 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[]>;
  27009. /**
  27010. * Creates a new animation, merges it with the existing animations and starts it
  27011. * @param name Name of the animation
  27012. * @param node Node which contains the scene that begins the animations
  27013. * @param targetProperty Specifies which property to animate
  27014. * @param framePerSecond The frames per second of the animation
  27015. * @param totalFrame The total number of frames
  27016. * @param from The frame at the beginning of the animation
  27017. * @param to The frame at the end of the animation
  27018. * @param loopMode Specifies the loop mode of the animation
  27019. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27020. * @param onAnimationEnd Callback to run once the animation is complete
  27021. * @returns Nullable animation
  27022. */
  27023. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27024. /**
  27025. * Transition property of an host to the target Value
  27026. * @param property The property to transition
  27027. * @param targetValue The target Value of the property
  27028. * @param host The object where the property to animate belongs
  27029. * @param scene Scene used to run the animation
  27030. * @param frameRate Framerate (in frame/s) to use
  27031. * @param transition The transition type we want to use
  27032. * @param duration The duration of the animation, in milliseconds
  27033. * @param onAnimationEnd Callback trigger at the end of the animation
  27034. * @returns Nullable animation
  27035. */
  27036. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27037. /**
  27038. * Return the array of runtime animations currently using this animation
  27039. */
  27040. readonly runtimeAnimations: RuntimeAnimation[];
  27041. /**
  27042. * Specifies if any of the runtime animations are currently running
  27043. */
  27044. readonly hasRunningRuntimeAnimations: boolean;
  27045. /**
  27046. * Initializes the animation
  27047. * @param name Name of the animation
  27048. * @param targetProperty Property to animate
  27049. * @param framePerSecond The frames per second of the animation
  27050. * @param dataType The data type of the animation
  27051. * @param loopMode The loop mode of the animation
  27052. * @param enableBlending Specifies if blending should be enabled
  27053. */
  27054. constructor(
  27055. /**Name of the animation */
  27056. name: string,
  27057. /**Property to animate */
  27058. targetProperty: string,
  27059. /**The frames per second of the animation */
  27060. framePerSecond: number,
  27061. /**The data type of the animation */
  27062. dataType: number,
  27063. /**The loop mode of the animation */
  27064. loopMode?: number | undefined,
  27065. /**Specifies if blending should be enabled */
  27066. enableBlending?: boolean | undefined);
  27067. /**
  27068. * Converts the animation to a string
  27069. * @param fullDetails support for multiple levels of logging within scene loading
  27070. * @returns String form of the animation
  27071. */
  27072. toString(fullDetails?: boolean): string;
  27073. /**
  27074. * Add an event to this animation
  27075. * @param event Event to add
  27076. */
  27077. addEvent(event: AnimationEvent): void;
  27078. /**
  27079. * Remove all events found at the given frame
  27080. * @param frame The frame to remove events from
  27081. */
  27082. removeEvents(frame: number): void;
  27083. /**
  27084. * Retrieves all the events from the animation
  27085. * @returns Events from the animation
  27086. */
  27087. getEvents(): AnimationEvent[];
  27088. /**
  27089. * Creates an animation range
  27090. * @param name Name of the animation range
  27091. * @param from Starting frame of the animation range
  27092. * @param to Ending frame of the animation
  27093. */
  27094. createRange(name: string, from: number, to: number): void;
  27095. /**
  27096. * Deletes an animation range by name
  27097. * @param name Name of the animation range to delete
  27098. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27099. */
  27100. deleteRange(name: string, deleteFrames?: boolean): void;
  27101. /**
  27102. * Gets the animation range by name, or null if not defined
  27103. * @param name Name of the animation range
  27104. * @returns Nullable animation range
  27105. */
  27106. getRange(name: string): Nullable<AnimationRange>;
  27107. /**
  27108. * Gets the key frames from the animation
  27109. * @returns The key frames of the animation
  27110. */
  27111. getKeys(): Array<IAnimationKey>;
  27112. /**
  27113. * Gets the highest frame rate of the animation
  27114. * @returns Highest frame rate of the animation
  27115. */
  27116. getHighestFrame(): number;
  27117. /**
  27118. * Gets the easing function of the animation
  27119. * @returns Easing function of the animation
  27120. */
  27121. getEasingFunction(): IEasingFunction;
  27122. /**
  27123. * Sets the easing function of the animation
  27124. * @param easingFunction A custom mathematical formula for animation
  27125. */
  27126. setEasingFunction(easingFunction: EasingFunction): void;
  27127. /**
  27128. * Interpolates a scalar linearly
  27129. * @param startValue Start value of the animation curve
  27130. * @param endValue End value of the animation curve
  27131. * @param gradient Scalar amount to interpolate
  27132. * @returns Interpolated scalar value
  27133. */
  27134. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27135. /**
  27136. * Interpolates a scalar cubically
  27137. * @param startValue Start value of the animation curve
  27138. * @param outTangent End tangent of the animation
  27139. * @param endValue End value of the animation curve
  27140. * @param inTangent Start tangent of the animation curve
  27141. * @param gradient Scalar amount to interpolate
  27142. * @returns Interpolated scalar value
  27143. */
  27144. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27145. /**
  27146. * Interpolates a quaternion using a spherical linear interpolation
  27147. * @param startValue Start value of the animation curve
  27148. * @param endValue End value of the animation curve
  27149. * @param gradient Scalar amount to interpolate
  27150. * @returns Interpolated quaternion value
  27151. */
  27152. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27153. /**
  27154. * Interpolates a quaternion cubically
  27155. * @param startValue Start value of the animation curve
  27156. * @param outTangent End tangent of the animation curve
  27157. * @param endValue End value of the animation curve
  27158. * @param inTangent Start tangent of the animation curve
  27159. * @param gradient Scalar amount to interpolate
  27160. * @returns Interpolated quaternion value
  27161. */
  27162. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27163. /**
  27164. * Interpolates a Vector3 linearl
  27165. * @param startValue Start value of the animation curve
  27166. * @param endValue End value of the animation curve
  27167. * @param gradient Scalar amount to interpolate
  27168. * @returns Interpolated scalar value
  27169. */
  27170. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27171. /**
  27172. * Interpolates a Vector3 cubically
  27173. * @param startValue Start value of the animation curve
  27174. * @param outTangent End tangent of the animation
  27175. * @param endValue End value of the animation curve
  27176. * @param inTangent Start tangent of the animation curve
  27177. * @param gradient Scalar amount to interpolate
  27178. * @returns InterpolatedVector3 value
  27179. */
  27180. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27181. /**
  27182. * Interpolates a Vector2 linearly
  27183. * @param startValue Start value of the animation curve
  27184. * @param endValue End value of the animation curve
  27185. * @param gradient Scalar amount to interpolate
  27186. * @returns Interpolated Vector2 value
  27187. */
  27188. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27189. /**
  27190. * Interpolates a Vector2 cubically
  27191. * @param startValue Start value of the animation curve
  27192. * @param outTangent End tangent of the animation
  27193. * @param endValue End value of the animation curve
  27194. * @param inTangent Start tangent of the animation curve
  27195. * @param gradient Scalar amount to interpolate
  27196. * @returns Interpolated Vector2 value
  27197. */
  27198. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27199. /**
  27200. * Interpolates a size linearly
  27201. * @param startValue Start value of the animation curve
  27202. * @param endValue End value of the animation curve
  27203. * @param gradient Scalar amount to interpolate
  27204. * @returns Interpolated Size value
  27205. */
  27206. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27207. /**
  27208. * Interpolates a Color3 linearly
  27209. * @param startValue Start value of the animation curve
  27210. * @param endValue End value of the animation curve
  27211. * @param gradient Scalar amount to interpolate
  27212. * @returns Interpolated Color3 value
  27213. */
  27214. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27215. /**
  27216. * @hidden Internal use only
  27217. */
  27218. _getKeyValue(value: any): any;
  27219. /**
  27220. * @hidden Internal use only
  27221. */
  27222. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27223. /**
  27224. * Defines the function to use to interpolate matrices
  27225. * @param startValue defines the start matrix
  27226. * @param endValue defines the end matrix
  27227. * @param gradient defines the gradient between both matrices
  27228. * @param result defines an optional target matrix where to store the interpolation
  27229. * @returns the interpolated matrix
  27230. */
  27231. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27232. /**
  27233. * Makes a copy of the animation
  27234. * @returns Cloned animation
  27235. */
  27236. clone(): Animation;
  27237. /**
  27238. * Sets the key frames of the animation
  27239. * @param values The animation key frames to set
  27240. */
  27241. setKeys(values: Array<IAnimationKey>): void;
  27242. /**
  27243. * Serializes the animation to an object
  27244. * @returns Serialized object
  27245. */
  27246. serialize(): any;
  27247. /**
  27248. * Float animation type
  27249. */
  27250. private static _ANIMATIONTYPE_FLOAT;
  27251. /**
  27252. * Vector3 animation type
  27253. */
  27254. private static _ANIMATIONTYPE_VECTOR3;
  27255. /**
  27256. * Quaternion animation type
  27257. */
  27258. private static _ANIMATIONTYPE_QUATERNION;
  27259. /**
  27260. * Matrix animation type
  27261. */
  27262. private static _ANIMATIONTYPE_MATRIX;
  27263. /**
  27264. * Color3 animation type
  27265. */
  27266. private static _ANIMATIONTYPE_COLOR3;
  27267. /**
  27268. * Vector2 animation type
  27269. */
  27270. private static _ANIMATIONTYPE_VECTOR2;
  27271. /**
  27272. * Size animation type
  27273. */
  27274. private static _ANIMATIONTYPE_SIZE;
  27275. /**
  27276. * Relative Loop Mode
  27277. */
  27278. private static _ANIMATIONLOOPMODE_RELATIVE;
  27279. /**
  27280. * Cycle Loop Mode
  27281. */
  27282. private static _ANIMATIONLOOPMODE_CYCLE;
  27283. /**
  27284. * Constant Loop Mode
  27285. */
  27286. private static _ANIMATIONLOOPMODE_CONSTANT;
  27287. /**
  27288. * Get the float animation type
  27289. */
  27290. static readonly ANIMATIONTYPE_FLOAT: number;
  27291. /**
  27292. * Get the Vector3 animation type
  27293. */
  27294. static readonly ANIMATIONTYPE_VECTOR3: number;
  27295. /**
  27296. * Get the Vector2 animation type
  27297. */
  27298. static readonly ANIMATIONTYPE_VECTOR2: number;
  27299. /**
  27300. * Get the Size animation type
  27301. */
  27302. static readonly ANIMATIONTYPE_SIZE: number;
  27303. /**
  27304. * Get the Quaternion animation type
  27305. */
  27306. static readonly ANIMATIONTYPE_QUATERNION: number;
  27307. /**
  27308. * Get the Matrix animation type
  27309. */
  27310. static readonly ANIMATIONTYPE_MATRIX: number;
  27311. /**
  27312. * Get the Color3 animation type
  27313. */
  27314. static readonly ANIMATIONTYPE_COLOR3: number;
  27315. /**
  27316. * Get the Relative Loop Mode
  27317. */
  27318. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27319. /**
  27320. * Get the Cycle Loop Mode
  27321. */
  27322. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27323. /**
  27324. * Get the Constant Loop Mode
  27325. */
  27326. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27327. /** @hidden */
  27328. static _UniversalLerp(left: any, right: any, amount: number): any;
  27329. /**
  27330. * Parses an animation object and creates an animation
  27331. * @param parsedAnimation Parsed animation object
  27332. * @returns Animation object
  27333. */
  27334. static Parse(parsedAnimation: any): Animation;
  27335. /**
  27336. * Appends the serialized animations from the source animations
  27337. * @param source Source containing the animations
  27338. * @param destination Target to store the animations
  27339. */
  27340. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27341. }
  27342. }
  27343. declare module BABYLON {
  27344. /**
  27345. * Interface containing an array of animations
  27346. */
  27347. export interface IAnimatable {
  27348. /**
  27349. * Array of animations
  27350. */
  27351. animations: Nullable<Array<Animation>>;
  27352. }
  27353. }
  27354. declare module BABYLON {
  27355. /**
  27356. * This represents all the required information to add a fresnel effect on a material:
  27357. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27358. */
  27359. export class FresnelParameters {
  27360. private _isEnabled;
  27361. /**
  27362. * Define if the fresnel effect is enable or not.
  27363. */
  27364. isEnabled: boolean;
  27365. /**
  27366. * Define the color used on edges (grazing angle)
  27367. */
  27368. leftColor: Color3;
  27369. /**
  27370. * Define the color used on center
  27371. */
  27372. rightColor: Color3;
  27373. /**
  27374. * Define bias applied to computed fresnel term
  27375. */
  27376. bias: number;
  27377. /**
  27378. * Defined the power exponent applied to fresnel term
  27379. */
  27380. power: number;
  27381. /**
  27382. * Clones the current fresnel and its valuues
  27383. * @returns a clone fresnel configuration
  27384. */
  27385. clone(): FresnelParameters;
  27386. /**
  27387. * Serializes the current fresnel parameters to a JSON representation.
  27388. * @return the JSON serialization
  27389. */
  27390. serialize(): any;
  27391. /**
  27392. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27393. * @param parsedFresnelParameters Define the JSON representation
  27394. * @returns the parsed parameters
  27395. */
  27396. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27397. }
  27398. }
  27399. declare module BABYLON {
  27400. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27401. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27402. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27403. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27404. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27405. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27406. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27407. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27408. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27409. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27410. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27411. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27412. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27413. /**
  27414. * Decorator used to define property that can be serialized as reference to a camera
  27415. * @param sourceName defines the name of the property to decorate
  27416. */
  27417. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27418. /**
  27419. * Class used to help serialization objects
  27420. */
  27421. export class SerializationHelper {
  27422. /** @hidden */
  27423. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27424. /** @hidden */
  27425. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27426. /** @hidden */
  27427. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27428. /** @hidden */
  27429. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27430. /**
  27431. * Appends the serialized animations from the source animations
  27432. * @param source Source containing the animations
  27433. * @param destination Target to store the animations
  27434. */
  27435. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27436. /**
  27437. * Static function used to serialized a specific entity
  27438. * @param entity defines the entity to serialize
  27439. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27440. * @returns a JSON compatible object representing the serialization of the entity
  27441. */
  27442. static Serialize<T>(entity: T, serializationObject?: any): any;
  27443. /**
  27444. * Creates a new entity from a serialization data object
  27445. * @param creationFunction defines a function used to instanciated the new entity
  27446. * @param source defines the source serialization data
  27447. * @param scene defines the hosting scene
  27448. * @param rootUrl defines the root url for resources
  27449. * @returns a new entity
  27450. */
  27451. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27452. /**
  27453. * Clones an object
  27454. * @param creationFunction defines the function used to instanciate the new object
  27455. * @param source defines the source object
  27456. * @returns the cloned object
  27457. */
  27458. static Clone<T>(creationFunction: () => T, source: T): T;
  27459. /**
  27460. * Instanciates a new object based on a source one (some data will be shared between both object)
  27461. * @param creationFunction defines the function used to instanciate the new object
  27462. * @param source defines the source object
  27463. * @returns the new object
  27464. */
  27465. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27466. }
  27467. }
  27468. declare module BABYLON {
  27469. /**
  27470. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27471. */
  27472. export interface CubeMapInfo {
  27473. /**
  27474. * The pixel array for the front face.
  27475. * This is stored in format, left to right, up to down format.
  27476. */
  27477. front: Nullable<ArrayBufferView>;
  27478. /**
  27479. * The pixel array for the back face.
  27480. * This is stored in format, left to right, up to down format.
  27481. */
  27482. back: Nullable<ArrayBufferView>;
  27483. /**
  27484. * The pixel array for the left face.
  27485. * This is stored in format, left to right, up to down format.
  27486. */
  27487. left: Nullable<ArrayBufferView>;
  27488. /**
  27489. * The pixel array for the right face.
  27490. * This is stored in format, left to right, up to down format.
  27491. */
  27492. right: Nullable<ArrayBufferView>;
  27493. /**
  27494. * The pixel array for the up face.
  27495. * This is stored in format, left to right, up to down format.
  27496. */
  27497. up: Nullable<ArrayBufferView>;
  27498. /**
  27499. * The pixel array for the down face.
  27500. * This is stored in format, left to right, up to down format.
  27501. */
  27502. down: Nullable<ArrayBufferView>;
  27503. /**
  27504. * The size of the cubemap stored.
  27505. *
  27506. * Each faces will be size * size pixels.
  27507. */
  27508. size: number;
  27509. /**
  27510. * The format of the texture.
  27511. *
  27512. * RGBA, RGB.
  27513. */
  27514. format: number;
  27515. /**
  27516. * The type of the texture data.
  27517. *
  27518. * UNSIGNED_INT, FLOAT.
  27519. */
  27520. type: number;
  27521. /**
  27522. * Specifies whether the texture is in gamma space.
  27523. */
  27524. gammaSpace: boolean;
  27525. }
  27526. /**
  27527. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27528. */
  27529. export class PanoramaToCubeMapTools {
  27530. private static FACE_FRONT;
  27531. private static FACE_BACK;
  27532. private static FACE_RIGHT;
  27533. private static FACE_LEFT;
  27534. private static FACE_DOWN;
  27535. private static FACE_UP;
  27536. /**
  27537. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27538. *
  27539. * @param float32Array The source data.
  27540. * @param inputWidth The width of the input panorama.
  27541. * @param inputHeight The height of the input panorama.
  27542. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27543. * @return The cubemap data
  27544. */
  27545. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27546. private static CreateCubemapTexture;
  27547. private static CalcProjectionSpherical;
  27548. }
  27549. }
  27550. declare module BABYLON {
  27551. /**
  27552. * Helper class dealing with the extraction of spherical polynomial dataArray
  27553. * from a cube map.
  27554. */
  27555. export class CubeMapToSphericalPolynomialTools {
  27556. private static FileFaces;
  27557. /**
  27558. * Converts a texture to the according Spherical Polynomial data.
  27559. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27560. *
  27561. * @param texture The texture to extract the information from.
  27562. * @return The Spherical Polynomial data.
  27563. */
  27564. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27565. /**
  27566. * Converts a cubemap to the according Spherical Polynomial data.
  27567. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27568. *
  27569. * @param cubeInfo The Cube map to extract the information from.
  27570. * @return The Spherical Polynomial data.
  27571. */
  27572. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27573. }
  27574. }
  27575. declare module BABYLON {
  27576. /**
  27577. * Class used to manipulate GUIDs
  27578. */
  27579. export class GUID {
  27580. /**
  27581. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27582. * Be aware Math.random() could cause collisions, but:
  27583. * "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"
  27584. * @returns a pseudo random id
  27585. */
  27586. static RandomId(): string;
  27587. }
  27588. }
  27589. declare module BABYLON {
  27590. /**
  27591. * Base class of all the textures in babylon.
  27592. * It groups all the common properties the materials, post process, lights... might need
  27593. * in order to make a correct use of the texture.
  27594. */
  27595. export class BaseTexture implements IAnimatable {
  27596. /**
  27597. * Default anisotropic filtering level for the application.
  27598. * It is set to 4 as a good tradeoff between perf and quality.
  27599. */
  27600. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27601. /**
  27602. * Gets or sets the unique id of the texture
  27603. */
  27604. uniqueId: number;
  27605. /**
  27606. * Define the name of the texture.
  27607. */
  27608. name: string;
  27609. /**
  27610. * Gets or sets an object used to store user defined information.
  27611. */
  27612. metadata: any;
  27613. /**
  27614. * For internal use only. Please do not use.
  27615. */
  27616. reservedDataStore: any;
  27617. private _hasAlpha;
  27618. /**
  27619. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27620. */
  27621. hasAlpha: boolean;
  27622. /**
  27623. * Defines if the alpha value should be determined via the rgb values.
  27624. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27625. */
  27626. getAlphaFromRGB: boolean;
  27627. /**
  27628. * Intensity or strength of the texture.
  27629. * It is commonly used by materials to fine tune the intensity of the texture
  27630. */
  27631. level: number;
  27632. /**
  27633. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27634. * This is part of the texture as textures usually maps to one uv set.
  27635. */
  27636. coordinatesIndex: number;
  27637. private _coordinatesMode;
  27638. /**
  27639. * How a texture is mapped.
  27640. *
  27641. * | Value | Type | Description |
  27642. * | ----- | ----------------------------------- | ----------- |
  27643. * | 0 | EXPLICIT_MODE | |
  27644. * | 1 | SPHERICAL_MODE | |
  27645. * | 2 | PLANAR_MODE | |
  27646. * | 3 | CUBIC_MODE | |
  27647. * | 4 | PROJECTION_MODE | |
  27648. * | 5 | SKYBOX_MODE | |
  27649. * | 6 | INVCUBIC_MODE | |
  27650. * | 7 | EQUIRECTANGULAR_MODE | |
  27651. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27652. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27653. */
  27654. coordinatesMode: number;
  27655. /**
  27656. * | Value | Type | Description |
  27657. * | ----- | ------------------ | ----------- |
  27658. * | 0 | CLAMP_ADDRESSMODE | |
  27659. * | 1 | WRAP_ADDRESSMODE | |
  27660. * | 2 | MIRROR_ADDRESSMODE | |
  27661. */
  27662. wrapU: number;
  27663. /**
  27664. * | Value | Type | Description |
  27665. * | ----- | ------------------ | ----------- |
  27666. * | 0 | CLAMP_ADDRESSMODE | |
  27667. * | 1 | WRAP_ADDRESSMODE | |
  27668. * | 2 | MIRROR_ADDRESSMODE | |
  27669. */
  27670. wrapV: number;
  27671. /**
  27672. * | Value | Type | Description |
  27673. * | ----- | ------------------ | ----------- |
  27674. * | 0 | CLAMP_ADDRESSMODE | |
  27675. * | 1 | WRAP_ADDRESSMODE | |
  27676. * | 2 | MIRROR_ADDRESSMODE | |
  27677. */
  27678. wrapR: number;
  27679. /**
  27680. * With compliant hardware and browser (supporting anisotropic filtering)
  27681. * this defines the level of anisotropic filtering in the texture.
  27682. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27683. */
  27684. anisotropicFilteringLevel: number;
  27685. /**
  27686. * Define if the texture is a cube texture or if false a 2d texture.
  27687. */
  27688. isCube: boolean;
  27689. /**
  27690. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27691. */
  27692. is3D: boolean;
  27693. /**
  27694. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27695. * HDR texture are usually stored in linear space.
  27696. * This only impacts the PBR and Background materials
  27697. */
  27698. gammaSpace: boolean;
  27699. /**
  27700. * Gets or sets whether or not the texture contains RGBD data.
  27701. */
  27702. isRGBD: boolean;
  27703. /**
  27704. * Is Z inverted in the texture (useful in a cube texture).
  27705. */
  27706. invertZ: boolean;
  27707. /**
  27708. * Are mip maps generated for this texture or not.
  27709. */
  27710. readonly noMipmap: boolean;
  27711. /**
  27712. * @hidden
  27713. */
  27714. lodLevelInAlpha: boolean;
  27715. /**
  27716. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27717. */
  27718. lodGenerationOffset: number;
  27719. /**
  27720. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27721. */
  27722. lodGenerationScale: number;
  27723. /**
  27724. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27725. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27726. * average roughness values.
  27727. */
  27728. linearSpecularLOD: boolean;
  27729. /**
  27730. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27731. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27732. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27733. */
  27734. irradianceTexture: Nullable<BaseTexture>;
  27735. /**
  27736. * Define if the texture is a render target.
  27737. */
  27738. isRenderTarget: boolean;
  27739. /**
  27740. * Define the unique id of the texture in the scene.
  27741. */
  27742. readonly uid: string;
  27743. /**
  27744. * Return a string representation of the texture.
  27745. * @returns the texture as a string
  27746. */
  27747. toString(): string;
  27748. /**
  27749. * Get the class name of the texture.
  27750. * @returns "BaseTexture"
  27751. */
  27752. getClassName(): string;
  27753. /**
  27754. * Define the list of animation attached to the texture.
  27755. */
  27756. animations: Animation[];
  27757. /**
  27758. * An event triggered when the texture is disposed.
  27759. */
  27760. onDisposeObservable: Observable<BaseTexture>;
  27761. private _onDisposeObserver;
  27762. /**
  27763. * Callback triggered when the texture has been disposed.
  27764. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27765. */
  27766. onDispose: () => void;
  27767. /**
  27768. * Define the current state of the loading sequence when in delayed load mode.
  27769. */
  27770. delayLoadState: number;
  27771. private _scene;
  27772. /** @hidden */
  27773. _texture: Nullable<InternalTexture>;
  27774. private _uid;
  27775. /**
  27776. * Define if the texture is preventinga material to render or not.
  27777. * If not and the texture is not ready, the engine will use a default black texture instead.
  27778. */
  27779. readonly isBlocking: boolean;
  27780. /**
  27781. * Instantiates a new BaseTexture.
  27782. * Base class of all the textures in babylon.
  27783. * It groups all the common properties the materials, post process, lights... might need
  27784. * in order to make a correct use of the texture.
  27785. * @param scene Define the scene the texture blongs to
  27786. */
  27787. constructor(scene: Nullable<Scene>);
  27788. /**
  27789. * Get the scene the texture belongs to.
  27790. * @returns the scene or null if undefined
  27791. */
  27792. getScene(): Nullable<Scene>;
  27793. /**
  27794. * Get the texture transform matrix used to offset tile the texture for istance.
  27795. * @returns the transformation matrix
  27796. */
  27797. getTextureMatrix(): Matrix;
  27798. /**
  27799. * Get the texture reflection matrix used to rotate/transform the reflection.
  27800. * @returns the reflection matrix
  27801. */
  27802. getReflectionTextureMatrix(): Matrix;
  27803. /**
  27804. * Get the underlying lower level texture from Babylon.
  27805. * @returns the insternal texture
  27806. */
  27807. getInternalTexture(): Nullable<InternalTexture>;
  27808. /**
  27809. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27810. * @returns true if ready or not blocking
  27811. */
  27812. isReadyOrNotBlocking(): boolean;
  27813. /**
  27814. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27815. * @returns true if fully ready
  27816. */
  27817. isReady(): boolean;
  27818. private _cachedSize;
  27819. /**
  27820. * Get the size of the texture.
  27821. * @returns the texture size.
  27822. */
  27823. getSize(): ISize;
  27824. /**
  27825. * Get the base size of the texture.
  27826. * It can be different from the size if the texture has been resized for POT for instance
  27827. * @returns the base size
  27828. */
  27829. getBaseSize(): ISize;
  27830. /**
  27831. * Update the sampling mode of the texture.
  27832. * Default is Trilinear mode.
  27833. *
  27834. * | Value | Type | Description |
  27835. * | ----- | ------------------ | ----------- |
  27836. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27837. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27838. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27839. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27840. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27841. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27842. * | 7 | NEAREST_LINEAR | |
  27843. * | 8 | NEAREST_NEAREST | |
  27844. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27845. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27846. * | 11 | LINEAR_LINEAR | |
  27847. * | 12 | LINEAR_NEAREST | |
  27848. *
  27849. * > _mag_: magnification filter (close to the viewer)
  27850. * > _min_: minification filter (far from the viewer)
  27851. * > _mip_: filter used between mip map levels
  27852. *@param samplingMode Define the new sampling mode of the texture
  27853. */
  27854. updateSamplingMode(samplingMode: number): void;
  27855. /**
  27856. * Scales the texture if is `canRescale()`
  27857. * @param ratio the resize factor we want to use to rescale
  27858. */
  27859. scale(ratio: number): void;
  27860. /**
  27861. * Get if the texture can rescale.
  27862. */
  27863. readonly canRescale: boolean;
  27864. /** @hidden */
  27865. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27866. /** @hidden */
  27867. _rebuild(): void;
  27868. /**
  27869. * Triggers the load sequence in delayed load mode.
  27870. */
  27871. delayLoad(): void;
  27872. /**
  27873. * Clones the texture.
  27874. * @returns the cloned texture
  27875. */
  27876. clone(): Nullable<BaseTexture>;
  27877. /**
  27878. * Get the texture underlying type (INT, FLOAT...)
  27879. */
  27880. readonly textureType: number;
  27881. /**
  27882. * Get the texture underlying format (RGB, RGBA...)
  27883. */
  27884. readonly textureFormat: number;
  27885. /**
  27886. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27887. * This will returns an RGBA array buffer containing either in values (0-255) or
  27888. * float values (0-1) depending of the underlying buffer type.
  27889. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27890. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27891. * @param buffer defines a user defined buffer to fill with data (can be null)
  27892. * @returns The Array buffer containing the pixels data.
  27893. */
  27894. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27895. /**
  27896. * Release and destroy the underlying lower level texture aka internalTexture.
  27897. */
  27898. releaseInternalTexture(): void;
  27899. /**
  27900. * Get the polynomial representation of the texture data.
  27901. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27902. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27903. */
  27904. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27905. /** @hidden */
  27906. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27907. /** @hidden */
  27908. readonly _lodTextureMid: Nullable<BaseTexture>;
  27909. /** @hidden */
  27910. readonly _lodTextureLow: Nullable<BaseTexture>;
  27911. /**
  27912. * Dispose the texture and release its associated resources.
  27913. */
  27914. dispose(): void;
  27915. /**
  27916. * Serialize the texture into a JSON representation that can be parsed later on.
  27917. * @returns the JSON representation of the texture
  27918. */
  27919. serialize(): any;
  27920. /**
  27921. * Helper function to be called back once a list of texture contains only ready textures.
  27922. * @param textures Define the list of textures to wait for
  27923. * @param callback Define the callback triggered once the entire list will be ready
  27924. */
  27925. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27926. }
  27927. }
  27928. declare module BABYLON {
  27929. /**
  27930. * Class used to store data associated with WebGL texture data for the engine
  27931. * This class should not be used directly
  27932. */
  27933. export class InternalTexture {
  27934. /** @hidden */
  27935. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27936. /**
  27937. * The source of the texture data is unknown
  27938. */
  27939. static DATASOURCE_UNKNOWN: number;
  27940. /**
  27941. * Texture data comes from an URL
  27942. */
  27943. static DATASOURCE_URL: number;
  27944. /**
  27945. * Texture data is only used for temporary storage
  27946. */
  27947. static DATASOURCE_TEMP: number;
  27948. /**
  27949. * Texture data comes from raw data (ArrayBuffer)
  27950. */
  27951. static DATASOURCE_RAW: number;
  27952. /**
  27953. * Texture content is dynamic (video or dynamic texture)
  27954. */
  27955. static DATASOURCE_DYNAMIC: number;
  27956. /**
  27957. * Texture content is generated by rendering to it
  27958. */
  27959. static DATASOURCE_RENDERTARGET: number;
  27960. /**
  27961. * Texture content is part of a multi render target process
  27962. */
  27963. static DATASOURCE_MULTIRENDERTARGET: number;
  27964. /**
  27965. * Texture data comes from a cube data file
  27966. */
  27967. static DATASOURCE_CUBE: number;
  27968. /**
  27969. * Texture data comes from a raw cube data
  27970. */
  27971. static DATASOURCE_CUBERAW: number;
  27972. /**
  27973. * Texture data come from a prefiltered cube data file
  27974. */
  27975. static DATASOURCE_CUBEPREFILTERED: number;
  27976. /**
  27977. * Texture content is raw 3D data
  27978. */
  27979. static DATASOURCE_RAW3D: number;
  27980. /**
  27981. * Texture content is a depth texture
  27982. */
  27983. static DATASOURCE_DEPTHTEXTURE: number;
  27984. /**
  27985. * Texture data comes from a raw cube data encoded with RGBD
  27986. */
  27987. static DATASOURCE_CUBERAW_RGBD: number;
  27988. /**
  27989. * Defines if the texture is ready
  27990. */
  27991. isReady: boolean;
  27992. /**
  27993. * Defines if the texture is a cube texture
  27994. */
  27995. isCube: boolean;
  27996. /**
  27997. * Defines if the texture contains 3D data
  27998. */
  27999. is3D: boolean;
  28000. /**
  28001. * Defines if the texture contains multiview data
  28002. */
  28003. isMultiview: boolean;
  28004. /**
  28005. * Gets the URL used to load this texture
  28006. */
  28007. url: string;
  28008. /**
  28009. * Gets the sampling mode of the texture
  28010. */
  28011. samplingMode: number;
  28012. /**
  28013. * Gets a boolean indicating if the texture needs mipmaps generation
  28014. */
  28015. generateMipMaps: boolean;
  28016. /**
  28017. * Gets the number of samples used by the texture (WebGL2+ only)
  28018. */
  28019. samples: number;
  28020. /**
  28021. * Gets the type of the texture (int, float...)
  28022. */
  28023. type: number;
  28024. /**
  28025. * Gets the format of the texture (RGB, RGBA...)
  28026. */
  28027. format: number;
  28028. /**
  28029. * Observable called when the texture is loaded
  28030. */
  28031. onLoadedObservable: Observable<InternalTexture>;
  28032. /**
  28033. * Gets the width of the texture
  28034. */
  28035. width: number;
  28036. /**
  28037. * Gets the height of the texture
  28038. */
  28039. height: number;
  28040. /**
  28041. * Gets the depth of the texture
  28042. */
  28043. depth: number;
  28044. /**
  28045. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28046. */
  28047. baseWidth: number;
  28048. /**
  28049. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28050. */
  28051. baseHeight: number;
  28052. /**
  28053. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28054. */
  28055. baseDepth: number;
  28056. /**
  28057. * Gets a boolean indicating if the texture is inverted on Y axis
  28058. */
  28059. invertY: boolean;
  28060. /** @hidden */
  28061. _invertVScale: boolean;
  28062. /** @hidden */
  28063. _associatedChannel: number;
  28064. /** @hidden */
  28065. _dataSource: number;
  28066. /** @hidden */
  28067. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28068. /** @hidden */
  28069. _bufferView: Nullable<ArrayBufferView>;
  28070. /** @hidden */
  28071. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28072. /** @hidden */
  28073. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28074. /** @hidden */
  28075. _size: number;
  28076. /** @hidden */
  28077. _extension: string;
  28078. /** @hidden */
  28079. _files: Nullable<string[]>;
  28080. /** @hidden */
  28081. _workingCanvas: Nullable<HTMLCanvasElement>;
  28082. /** @hidden */
  28083. _workingContext: Nullable<CanvasRenderingContext2D>;
  28084. /** @hidden */
  28085. _framebuffer: Nullable<WebGLFramebuffer>;
  28086. /** @hidden */
  28087. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28088. /** @hidden */
  28089. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28090. /** @hidden */
  28091. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28092. /** @hidden */
  28093. _attachments: Nullable<number[]>;
  28094. /** @hidden */
  28095. _cachedCoordinatesMode: Nullable<number>;
  28096. /** @hidden */
  28097. _cachedWrapU: Nullable<number>;
  28098. /** @hidden */
  28099. _cachedWrapV: Nullable<number>;
  28100. /** @hidden */
  28101. _cachedWrapR: Nullable<number>;
  28102. /** @hidden */
  28103. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28104. /** @hidden */
  28105. _isDisabled: boolean;
  28106. /** @hidden */
  28107. _compression: Nullable<string>;
  28108. /** @hidden */
  28109. _generateStencilBuffer: boolean;
  28110. /** @hidden */
  28111. _generateDepthBuffer: boolean;
  28112. /** @hidden */
  28113. _comparisonFunction: number;
  28114. /** @hidden */
  28115. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28116. /** @hidden */
  28117. _lodGenerationScale: number;
  28118. /** @hidden */
  28119. _lodGenerationOffset: number;
  28120. /** @hidden */
  28121. _colorTextureArray: Nullable<WebGLTexture>;
  28122. /** @hidden */
  28123. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28124. /** @hidden */
  28125. _lodTextureHigh: Nullable<BaseTexture>;
  28126. /** @hidden */
  28127. _lodTextureMid: Nullable<BaseTexture>;
  28128. /** @hidden */
  28129. _lodTextureLow: Nullable<BaseTexture>;
  28130. /** @hidden */
  28131. _isRGBD: boolean;
  28132. /** @hidden */
  28133. _linearSpecularLOD: boolean;
  28134. /** @hidden */
  28135. _irradianceTexture: Nullable<BaseTexture>;
  28136. /** @hidden */
  28137. _webGLTexture: Nullable<WebGLTexture>;
  28138. /** @hidden */
  28139. _references: number;
  28140. private _engine;
  28141. /**
  28142. * Gets the Engine the texture belongs to.
  28143. * @returns The babylon engine
  28144. */
  28145. getEngine(): Engine;
  28146. /**
  28147. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28148. */
  28149. readonly dataSource: number;
  28150. /**
  28151. * Creates a new InternalTexture
  28152. * @param engine defines the engine to use
  28153. * @param dataSource defines the type of data that will be used
  28154. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28155. */
  28156. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28157. /**
  28158. * Increments the number of references (ie. the number of Texture that point to it)
  28159. */
  28160. incrementReferences(): void;
  28161. /**
  28162. * Change the size of the texture (not the size of the content)
  28163. * @param width defines the new width
  28164. * @param height defines the new height
  28165. * @param depth defines the new depth (1 by default)
  28166. */
  28167. updateSize(width: int, height: int, depth?: int): void;
  28168. /** @hidden */
  28169. _rebuild(): void;
  28170. /** @hidden */
  28171. _swapAndDie(target: InternalTexture): void;
  28172. /**
  28173. * Dispose the current allocated resources
  28174. */
  28175. dispose(): void;
  28176. }
  28177. }
  28178. declare module BABYLON {
  28179. /**
  28180. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28181. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28182. */
  28183. export class EffectFallbacks {
  28184. private _defines;
  28185. private _currentRank;
  28186. private _maxRank;
  28187. private _mesh;
  28188. /**
  28189. * Removes the fallback from the bound mesh.
  28190. */
  28191. unBindMesh(): void;
  28192. /**
  28193. * Adds a fallback on the specified property.
  28194. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28195. * @param define The name of the define in the shader
  28196. */
  28197. addFallback(rank: number, define: string): void;
  28198. /**
  28199. * Sets the mesh to use CPU skinning when needing to fallback.
  28200. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28201. * @param mesh The mesh to use the fallbacks.
  28202. */
  28203. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28204. /**
  28205. * Checks to see if more fallbacks are still availible.
  28206. */
  28207. readonly hasMoreFallbacks: boolean;
  28208. /**
  28209. * Removes the defines that should be removed when falling back.
  28210. * @param currentDefines defines the current define statements for the shader.
  28211. * @param effect defines the current effect we try to compile
  28212. * @returns The resulting defines with defines of the current rank removed.
  28213. */
  28214. reduce(currentDefines: string, effect: Effect): string;
  28215. }
  28216. /**
  28217. * Options to be used when creating an effect.
  28218. */
  28219. export class EffectCreationOptions {
  28220. /**
  28221. * Atrributes that will be used in the shader.
  28222. */
  28223. attributes: string[];
  28224. /**
  28225. * Uniform varible names that will be set in the shader.
  28226. */
  28227. uniformsNames: string[];
  28228. /**
  28229. * Uniform buffer varible names that will be set in the shader.
  28230. */
  28231. uniformBuffersNames: string[];
  28232. /**
  28233. * Sampler texture variable names that will be set in the shader.
  28234. */
  28235. samplers: string[];
  28236. /**
  28237. * Define statements that will be set in the shader.
  28238. */
  28239. defines: any;
  28240. /**
  28241. * Possible fallbacks for this effect to improve performance when needed.
  28242. */
  28243. fallbacks: Nullable<EffectFallbacks>;
  28244. /**
  28245. * Callback that will be called when the shader is compiled.
  28246. */
  28247. onCompiled: Nullable<(effect: Effect) => void>;
  28248. /**
  28249. * Callback that will be called if an error occurs during shader compilation.
  28250. */
  28251. onError: Nullable<(effect: Effect, errors: string) => void>;
  28252. /**
  28253. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28254. */
  28255. indexParameters: any;
  28256. /**
  28257. * Max number of lights that can be used in the shader.
  28258. */
  28259. maxSimultaneousLights: number;
  28260. /**
  28261. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28262. */
  28263. transformFeedbackVaryings: Nullable<string[]>;
  28264. }
  28265. /**
  28266. * Effect containing vertex and fragment shader that can be executed on an object.
  28267. */
  28268. export class Effect implements IDisposable {
  28269. /**
  28270. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28271. */
  28272. static ShadersRepository: string;
  28273. /**
  28274. * Name of the effect.
  28275. */
  28276. name: any;
  28277. /**
  28278. * String container all the define statements that should be set on the shader.
  28279. */
  28280. defines: string;
  28281. /**
  28282. * Callback that will be called when the shader is compiled.
  28283. */
  28284. onCompiled: Nullable<(effect: Effect) => void>;
  28285. /**
  28286. * Callback that will be called if an error occurs during shader compilation.
  28287. */
  28288. onError: Nullable<(effect: Effect, errors: string) => void>;
  28289. /**
  28290. * Callback that will be called when effect is bound.
  28291. */
  28292. onBind: Nullable<(effect: Effect) => void>;
  28293. /**
  28294. * Unique ID of the effect.
  28295. */
  28296. uniqueId: number;
  28297. /**
  28298. * Observable that will be called when the shader is compiled.
  28299. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28300. */
  28301. onCompileObservable: Observable<Effect>;
  28302. /**
  28303. * Observable that will be called if an error occurs during shader compilation.
  28304. */
  28305. onErrorObservable: Observable<Effect>;
  28306. /** @hidden */
  28307. _onBindObservable: Nullable<Observable<Effect>>;
  28308. /**
  28309. * Observable that will be called when effect is bound.
  28310. */
  28311. readonly onBindObservable: Observable<Effect>;
  28312. /** @hidden */
  28313. _bonesComputationForcedToCPU: boolean;
  28314. private static _uniqueIdSeed;
  28315. private _engine;
  28316. private _uniformBuffersNames;
  28317. private _uniformsNames;
  28318. private _samplerList;
  28319. private _samplers;
  28320. private _isReady;
  28321. private _compilationError;
  28322. private _attributesNames;
  28323. private _attributes;
  28324. private _uniforms;
  28325. /**
  28326. * Key for the effect.
  28327. * @hidden
  28328. */
  28329. _key: string;
  28330. private _indexParameters;
  28331. private _fallbacks;
  28332. private _vertexSourceCode;
  28333. private _fragmentSourceCode;
  28334. private _vertexSourceCodeOverride;
  28335. private _fragmentSourceCodeOverride;
  28336. private _transformFeedbackVaryings;
  28337. /**
  28338. * Compiled shader to webGL program.
  28339. * @hidden
  28340. */
  28341. _pipelineContext: Nullable<IPipelineContext>;
  28342. private _valueCache;
  28343. private static _baseCache;
  28344. /**
  28345. * Instantiates an effect.
  28346. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28347. * @param baseName Name of the effect.
  28348. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28349. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28350. * @param samplers List of sampler variables that will be passed to the shader.
  28351. * @param engine Engine to be used to render the effect
  28352. * @param defines Define statements to be added to the shader.
  28353. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28354. * @param onCompiled Callback that will be called when the shader is compiled.
  28355. * @param onError Callback that will be called if an error occurs during shader compilation.
  28356. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28357. */
  28358. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28359. private _useFinalCode;
  28360. /**
  28361. * Unique key for this effect
  28362. */
  28363. readonly key: string;
  28364. /**
  28365. * If the effect has been compiled and prepared.
  28366. * @returns if the effect is compiled and prepared.
  28367. */
  28368. isReady(): boolean;
  28369. private _isReadyInternal;
  28370. /**
  28371. * The engine the effect was initialized with.
  28372. * @returns the engine.
  28373. */
  28374. getEngine(): Engine;
  28375. /**
  28376. * The pipeline context for this effect
  28377. * @returns the associated pipeline context
  28378. */
  28379. getPipelineContext(): Nullable<IPipelineContext>;
  28380. /**
  28381. * The set of names of attribute variables for the shader.
  28382. * @returns An array of attribute names.
  28383. */
  28384. getAttributesNames(): string[];
  28385. /**
  28386. * Returns the attribute at the given index.
  28387. * @param index The index of the attribute.
  28388. * @returns The location of the attribute.
  28389. */
  28390. getAttributeLocation(index: number): number;
  28391. /**
  28392. * Returns the attribute based on the name of the variable.
  28393. * @param name of the attribute to look up.
  28394. * @returns the attribute location.
  28395. */
  28396. getAttributeLocationByName(name: string): number;
  28397. /**
  28398. * The number of attributes.
  28399. * @returns the numnber of attributes.
  28400. */
  28401. getAttributesCount(): number;
  28402. /**
  28403. * Gets the index of a uniform variable.
  28404. * @param uniformName of the uniform to look up.
  28405. * @returns the index.
  28406. */
  28407. getUniformIndex(uniformName: string): number;
  28408. /**
  28409. * Returns the attribute based on the name of the variable.
  28410. * @param uniformName of the uniform to look up.
  28411. * @returns the location of the uniform.
  28412. */
  28413. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28414. /**
  28415. * Returns an array of sampler variable names
  28416. * @returns The array of sampler variable neames.
  28417. */
  28418. getSamplers(): string[];
  28419. /**
  28420. * The error from the last compilation.
  28421. * @returns the error string.
  28422. */
  28423. getCompilationError(): string;
  28424. /**
  28425. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28426. * @param func The callback to be used.
  28427. */
  28428. executeWhenCompiled(func: (effect: Effect) => void): void;
  28429. private _checkIsReady;
  28430. /** @hidden */
  28431. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28432. /** @hidden */
  28433. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28434. /** @hidden */
  28435. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28436. /**
  28437. * Recompiles the webGL program
  28438. * @param vertexSourceCode The source code for the vertex shader.
  28439. * @param fragmentSourceCode The source code for the fragment shader.
  28440. * @param onCompiled Callback called when completed.
  28441. * @param onError Callback called on error.
  28442. * @hidden
  28443. */
  28444. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28445. /**
  28446. * Prepares the effect
  28447. * @hidden
  28448. */
  28449. _prepareEffect(): void;
  28450. private _processCompilationErrors;
  28451. /**
  28452. * Checks if the effect is supported. (Must be called after compilation)
  28453. */
  28454. readonly isSupported: boolean;
  28455. /**
  28456. * Binds a texture to the engine to be used as output of the shader.
  28457. * @param channel Name of the output variable.
  28458. * @param texture Texture to bind.
  28459. * @hidden
  28460. */
  28461. _bindTexture(channel: string, texture: InternalTexture): void;
  28462. /**
  28463. * Sets a texture on the engine to be used in the shader.
  28464. * @param channel Name of the sampler variable.
  28465. * @param texture Texture to set.
  28466. */
  28467. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28468. /**
  28469. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28470. * @param channel Name of the sampler variable.
  28471. * @param texture Texture to set.
  28472. */
  28473. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28474. /**
  28475. * Sets an array of textures on the engine to be used in the shader.
  28476. * @param channel Name of the variable.
  28477. * @param textures Textures to set.
  28478. */
  28479. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28480. /**
  28481. * 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)
  28482. * @param channel Name of the sampler variable.
  28483. * @param postProcess Post process to get the input texture from.
  28484. */
  28485. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28486. /**
  28487. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28488. * 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)
  28489. * @param channel Name of the sampler variable.
  28490. * @param postProcess Post process to get the output texture from.
  28491. */
  28492. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28493. /** @hidden */
  28494. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28495. /** @hidden */
  28496. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28497. /** @hidden */
  28498. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28499. /** @hidden */
  28500. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28501. /**
  28502. * Binds a buffer to a uniform.
  28503. * @param buffer Buffer to bind.
  28504. * @param name Name of the uniform variable to bind to.
  28505. */
  28506. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28507. /**
  28508. * Binds block to a uniform.
  28509. * @param blockName Name of the block to bind.
  28510. * @param index Index to bind.
  28511. */
  28512. bindUniformBlock(blockName: string, index: number): void;
  28513. /**
  28514. * Sets an interger value on a uniform variable.
  28515. * @param uniformName Name of the variable.
  28516. * @param value Value to be set.
  28517. * @returns this effect.
  28518. */
  28519. setInt(uniformName: string, value: number): Effect;
  28520. /**
  28521. * Sets an int array on a uniform variable.
  28522. * @param uniformName Name of the variable.
  28523. * @param array array to be set.
  28524. * @returns this effect.
  28525. */
  28526. setIntArray(uniformName: string, array: Int32Array): Effect;
  28527. /**
  28528. * 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)
  28529. * @param uniformName Name of the variable.
  28530. * @param array array to be set.
  28531. * @returns this effect.
  28532. */
  28533. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28534. /**
  28535. * 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)
  28536. * @param uniformName Name of the variable.
  28537. * @param array array to be set.
  28538. * @returns this effect.
  28539. */
  28540. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28541. /**
  28542. * 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)
  28543. * @param uniformName Name of the variable.
  28544. * @param array array to be set.
  28545. * @returns this effect.
  28546. */
  28547. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28548. /**
  28549. * Sets an float array on a uniform variable.
  28550. * @param uniformName Name of the variable.
  28551. * @param array array to be set.
  28552. * @returns this effect.
  28553. */
  28554. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28555. /**
  28556. * 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)
  28557. * @param uniformName Name of the variable.
  28558. * @param array array to be set.
  28559. * @returns this effect.
  28560. */
  28561. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28562. /**
  28563. * 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)
  28564. * @param uniformName Name of the variable.
  28565. * @param array array to be set.
  28566. * @returns this effect.
  28567. */
  28568. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28569. /**
  28570. * 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)
  28571. * @param uniformName Name of the variable.
  28572. * @param array array to be set.
  28573. * @returns this effect.
  28574. */
  28575. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28576. /**
  28577. * Sets an array on a uniform variable.
  28578. * @param uniformName Name of the variable.
  28579. * @param array array to be set.
  28580. * @returns this effect.
  28581. */
  28582. setArray(uniformName: string, array: number[]): Effect;
  28583. /**
  28584. * 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)
  28585. * @param uniformName Name of the variable.
  28586. * @param array array to be set.
  28587. * @returns this effect.
  28588. */
  28589. setArray2(uniformName: string, array: number[]): Effect;
  28590. /**
  28591. * 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)
  28592. * @param uniformName Name of the variable.
  28593. * @param array array to be set.
  28594. * @returns this effect.
  28595. */
  28596. setArray3(uniformName: string, array: number[]): Effect;
  28597. /**
  28598. * 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)
  28599. * @param uniformName Name of the variable.
  28600. * @param array array to be set.
  28601. * @returns this effect.
  28602. */
  28603. setArray4(uniformName: string, array: number[]): Effect;
  28604. /**
  28605. * Sets matrices on a uniform variable.
  28606. * @param uniformName Name of the variable.
  28607. * @param matrices matrices to be set.
  28608. * @returns this effect.
  28609. */
  28610. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28611. /**
  28612. * Sets matrix on a uniform variable.
  28613. * @param uniformName Name of the variable.
  28614. * @param matrix matrix to be set.
  28615. * @returns this effect.
  28616. */
  28617. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28618. /**
  28619. * 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)
  28620. * @param uniformName Name of the variable.
  28621. * @param matrix matrix to be set.
  28622. * @returns this effect.
  28623. */
  28624. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28625. /**
  28626. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28627. * @param uniformName Name of the variable.
  28628. * @param matrix matrix to be set.
  28629. * @returns this effect.
  28630. */
  28631. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28632. /**
  28633. * Sets a float on a uniform variable.
  28634. * @param uniformName Name of the variable.
  28635. * @param value value to be set.
  28636. * @returns this effect.
  28637. */
  28638. setFloat(uniformName: string, value: number): Effect;
  28639. /**
  28640. * Sets a boolean on a uniform variable.
  28641. * @param uniformName Name of the variable.
  28642. * @param bool value to be set.
  28643. * @returns this effect.
  28644. */
  28645. setBool(uniformName: string, bool: boolean): Effect;
  28646. /**
  28647. * Sets a Vector2 on a uniform variable.
  28648. * @param uniformName Name of the variable.
  28649. * @param vector2 vector2 to be set.
  28650. * @returns this effect.
  28651. */
  28652. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28653. /**
  28654. * Sets a float2 on a uniform variable.
  28655. * @param uniformName Name of the variable.
  28656. * @param x First float in float2.
  28657. * @param y Second float in float2.
  28658. * @returns this effect.
  28659. */
  28660. setFloat2(uniformName: string, x: number, y: number): Effect;
  28661. /**
  28662. * Sets a Vector3 on a uniform variable.
  28663. * @param uniformName Name of the variable.
  28664. * @param vector3 Value to be set.
  28665. * @returns this effect.
  28666. */
  28667. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28668. /**
  28669. * Sets a float3 on a uniform variable.
  28670. * @param uniformName Name of the variable.
  28671. * @param x First float in float3.
  28672. * @param y Second float in float3.
  28673. * @param z Third float in float3.
  28674. * @returns this effect.
  28675. */
  28676. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28677. /**
  28678. * Sets a Vector4 on a uniform variable.
  28679. * @param uniformName Name of the variable.
  28680. * @param vector4 Value to be set.
  28681. * @returns this effect.
  28682. */
  28683. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28684. /**
  28685. * Sets a float4 on a uniform variable.
  28686. * @param uniformName Name of the variable.
  28687. * @param x First float in float4.
  28688. * @param y Second float in float4.
  28689. * @param z Third float in float4.
  28690. * @param w Fourth float in float4.
  28691. * @returns this effect.
  28692. */
  28693. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28694. /**
  28695. * Sets a Color3 on a uniform variable.
  28696. * @param uniformName Name of the variable.
  28697. * @param color3 Value to be set.
  28698. * @returns this effect.
  28699. */
  28700. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28701. /**
  28702. * Sets a Color4 on a uniform variable.
  28703. * @param uniformName Name of the variable.
  28704. * @param color3 Value to be set.
  28705. * @param alpha Alpha value to be set.
  28706. * @returns this effect.
  28707. */
  28708. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28709. /**
  28710. * Sets a Color4 on a uniform variable
  28711. * @param uniformName defines the name of the variable
  28712. * @param color4 defines the value to be set
  28713. * @returns this effect.
  28714. */
  28715. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28716. /** Release all associated resources */
  28717. dispose(): void;
  28718. /**
  28719. * This function will add a new shader to the shader store
  28720. * @param name the name of the shader
  28721. * @param pixelShader optional pixel shader content
  28722. * @param vertexShader optional vertex shader content
  28723. */
  28724. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28725. /**
  28726. * Store of each shader (The can be looked up using effect.key)
  28727. */
  28728. static ShadersStore: {
  28729. [key: string]: string;
  28730. };
  28731. /**
  28732. * Store of each included file for a shader (The can be looked up using effect.key)
  28733. */
  28734. static IncludesShadersStore: {
  28735. [key: string]: string;
  28736. };
  28737. /**
  28738. * Resets the cache of effects.
  28739. */
  28740. static ResetCache(): void;
  28741. }
  28742. }
  28743. declare module BABYLON {
  28744. /**
  28745. * Uniform buffer objects.
  28746. *
  28747. * Handles blocks of uniform on the GPU.
  28748. *
  28749. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28750. *
  28751. * For more information, please refer to :
  28752. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28753. */
  28754. export class UniformBuffer {
  28755. private _engine;
  28756. private _buffer;
  28757. private _data;
  28758. private _bufferData;
  28759. private _dynamic?;
  28760. private _uniformLocations;
  28761. private _uniformSizes;
  28762. private _uniformLocationPointer;
  28763. private _needSync;
  28764. private _noUBO;
  28765. private _currentEffect;
  28766. private static _MAX_UNIFORM_SIZE;
  28767. private static _tempBuffer;
  28768. /**
  28769. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28770. * This is dynamic to allow compat with webgl 1 and 2.
  28771. * You will need to pass the name of the uniform as well as the value.
  28772. */
  28773. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28774. /**
  28775. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28776. * This is dynamic to allow compat with webgl 1 and 2.
  28777. * You will need to pass the name of the uniform as well as the value.
  28778. */
  28779. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28780. /**
  28781. * Lambda to Update a single float in a uniform buffer.
  28782. * This is dynamic to allow compat with webgl 1 and 2.
  28783. * You will need to pass the name of the uniform as well as the value.
  28784. */
  28785. updateFloat: (name: string, x: number) => void;
  28786. /**
  28787. * Lambda to Update a vec2 of float in a uniform buffer.
  28788. * This is dynamic to allow compat with webgl 1 and 2.
  28789. * You will need to pass the name of the uniform as well as the value.
  28790. */
  28791. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28792. /**
  28793. * Lambda to Update a vec3 of float in a uniform buffer.
  28794. * This is dynamic to allow compat with webgl 1 and 2.
  28795. * You will need to pass the name of the uniform as well as the value.
  28796. */
  28797. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28798. /**
  28799. * Lambda to Update a vec4 of float in a uniform buffer.
  28800. * This is dynamic to allow compat with webgl 1 and 2.
  28801. * You will need to pass the name of the uniform as well as the value.
  28802. */
  28803. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28804. /**
  28805. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28806. * This is dynamic to allow compat with webgl 1 and 2.
  28807. * You will need to pass the name of the uniform as well as the value.
  28808. */
  28809. updateMatrix: (name: string, mat: Matrix) => void;
  28810. /**
  28811. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28812. * This is dynamic to allow compat with webgl 1 and 2.
  28813. * You will need to pass the name of the uniform as well as the value.
  28814. */
  28815. updateVector3: (name: string, vector: Vector3) => void;
  28816. /**
  28817. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28818. * This is dynamic to allow compat with webgl 1 and 2.
  28819. * You will need to pass the name of the uniform as well as the value.
  28820. */
  28821. updateVector4: (name: string, vector: Vector4) => void;
  28822. /**
  28823. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28824. * This is dynamic to allow compat with webgl 1 and 2.
  28825. * You will need to pass the name of the uniform as well as the value.
  28826. */
  28827. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28828. /**
  28829. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28830. * This is dynamic to allow compat with webgl 1 and 2.
  28831. * You will need to pass the name of the uniform as well as the value.
  28832. */
  28833. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28834. /**
  28835. * Instantiates a new Uniform buffer objects.
  28836. *
  28837. * Handles blocks of uniform on the GPU.
  28838. *
  28839. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28840. *
  28841. * For more information, please refer to :
  28842. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28843. * @param engine Define the engine the buffer is associated with
  28844. * @param data Define the data contained in the buffer
  28845. * @param dynamic Define if the buffer is updatable
  28846. */
  28847. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28848. /**
  28849. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28850. * or just falling back on setUniformXXX calls.
  28851. */
  28852. readonly useUbo: boolean;
  28853. /**
  28854. * Indicates if the WebGL underlying uniform buffer is in sync
  28855. * with the javascript cache data.
  28856. */
  28857. readonly isSync: boolean;
  28858. /**
  28859. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28860. * Also, a dynamic UniformBuffer will disable cache verification and always
  28861. * update the underlying WebGL uniform buffer to the GPU.
  28862. * @returns if Dynamic, otherwise false
  28863. */
  28864. isDynamic(): boolean;
  28865. /**
  28866. * The data cache on JS side.
  28867. * @returns the underlying data as a float array
  28868. */
  28869. getData(): Float32Array;
  28870. /**
  28871. * The underlying WebGL Uniform buffer.
  28872. * @returns the webgl buffer
  28873. */
  28874. getBuffer(): Nullable<DataBuffer>;
  28875. /**
  28876. * std140 layout specifies how to align data within an UBO structure.
  28877. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28878. * for specs.
  28879. */
  28880. private _fillAlignment;
  28881. /**
  28882. * Adds an uniform in the buffer.
  28883. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28884. * for the layout to be correct !
  28885. * @param name Name of the uniform, as used in the uniform block in the shader.
  28886. * @param size Data size, or data directly.
  28887. */
  28888. addUniform(name: string, size: number | number[]): void;
  28889. /**
  28890. * Adds a Matrix 4x4 to the uniform buffer.
  28891. * @param name Name of the uniform, as used in the uniform block in the shader.
  28892. * @param mat A 4x4 matrix.
  28893. */
  28894. addMatrix(name: string, mat: Matrix): void;
  28895. /**
  28896. * Adds a vec2 to the uniform buffer.
  28897. * @param name Name of the uniform, as used in the uniform block in the shader.
  28898. * @param x Define the x component value of the vec2
  28899. * @param y Define the y component value of the vec2
  28900. */
  28901. addFloat2(name: string, x: number, y: number): void;
  28902. /**
  28903. * Adds a vec3 to the uniform buffer.
  28904. * @param name Name of the uniform, as used in the uniform block in the shader.
  28905. * @param x Define the x component value of the vec3
  28906. * @param y Define the y component value of the vec3
  28907. * @param z Define the z component value of the vec3
  28908. */
  28909. addFloat3(name: string, x: number, y: number, z: number): void;
  28910. /**
  28911. * Adds a vec3 to the uniform buffer.
  28912. * @param name Name of the uniform, as used in the uniform block in the shader.
  28913. * @param color Define the vec3 from a Color
  28914. */
  28915. addColor3(name: string, color: Color3): void;
  28916. /**
  28917. * Adds a vec4 to the uniform buffer.
  28918. * @param name Name of the uniform, as used in the uniform block in the shader.
  28919. * @param color Define the rgb components from a Color
  28920. * @param alpha Define the a component of the vec4
  28921. */
  28922. addColor4(name: string, color: Color3, alpha: number): void;
  28923. /**
  28924. * Adds a vec3 to the uniform buffer.
  28925. * @param name Name of the uniform, as used in the uniform block in the shader.
  28926. * @param vector Define the vec3 components from a Vector
  28927. */
  28928. addVector3(name: string, vector: Vector3): void;
  28929. /**
  28930. * Adds a Matrix 3x3 to the uniform buffer.
  28931. * @param name Name of the uniform, as used in the uniform block in the shader.
  28932. */
  28933. addMatrix3x3(name: string): void;
  28934. /**
  28935. * Adds a Matrix 2x2 to the uniform buffer.
  28936. * @param name Name of the uniform, as used in the uniform block in the shader.
  28937. */
  28938. addMatrix2x2(name: string): void;
  28939. /**
  28940. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28941. */
  28942. create(): void;
  28943. /** @hidden */
  28944. _rebuild(): void;
  28945. /**
  28946. * Updates the WebGL Uniform Buffer on the GPU.
  28947. * If the `dynamic` flag is set to true, no cache comparison is done.
  28948. * Otherwise, the buffer will be updated only if the cache differs.
  28949. */
  28950. update(): void;
  28951. /**
  28952. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28953. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28954. * @param data Define the flattened data
  28955. * @param size Define the size of the data.
  28956. */
  28957. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28958. private _valueCache;
  28959. private _cacheMatrix;
  28960. private _updateMatrix3x3ForUniform;
  28961. private _updateMatrix3x3ForEffect;
  28962. private _updateMatrix2x2ForEffect;
  28963. private _updateMatrix2x2ForUniform;
  28964. private _updateFloatForEffect;
  28965. private _updateFloatForUniform;
  28966. private _updateFloat2ForEffect;
  28967. private _updateFloat2ForUniform;
  28968. private _updateFloat3ForEffect;
  28969. private _updateFloat3ForUniform;
  28970. private _updateFloat4ForEffect;
  28971. private _updateFloat4ForUniform;
  28972. private _updateMatrixForEffect;
  28973. private _updateMatrixForUniform;
  28974. private _updateVector3ForEffect;
  28975. private _updateVector3ForUniform;
  28976. private _updateVector4ForEffect;
  28977. private _updateVector4ForUniform;
  28978. private _updateColor3ForEffect;
  28979. private _updateColor3ForUniform;
  28980. private _updateColor4ForEffect;
  28981. private _updateColor4ForUniform;
  28982. /**
  28983. * Sets a sampler uniform on the effect.
  28984. * @param name Define the name of the sampler.
  28985. * @param texture Define the texture to set in the sampler
  28986. */
  28987. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28988. /**
  28989. * Directly updates the value of the uniform in the cache AND on the GPU.
  28990. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28991. * @param data Define the flattened data
  28992. */
  28993. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28994. /**
  28995. * Binds this uniform buffer to an effect.
  28996. * @param effect Define the effect to bind the buffer to
  28997. * @param name Name of the uniform block in the shader.
  28998. */
  28999. bindToEffect(effect: Effect, name: string): void;
  29000. /**
  29001. * Disposes the uniform buffer.
  29002. */
  29003. dispose(): void;
  29004. }
  29005. }
  29006. declare module BABYLON {
  29007. /**
  29008. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29010. */
  29011. export class Analyser {
  29012. /**
  29013. * Gets or sets the smoothing
  29014. * @ignorenaming
  29015. */
  29016. SMOOTHING: number;
  29017. /**
  29018. * Gets or sets the FFT table size
  29019. * @ignorenaming
  29020. */
  29021. FFT_SIZE: number;
  29022. /**
  29023. * Gets or sets the bar graph amplitude
  29024. * @ignorenaming
  29025. */
  29026. BARGRAPHAMPLITUDE: number;
  29027. /**
  29028. * Gets or sets the position of the debug canvas
  29029. * @ignorenaming
  29030. */
  29031. DEBUGCANVASPOS: {
  29032. x: number;
  29033. y: number;
  29034. };
  29035. /**
  29036. * Gets or sets the debug canvas size
  29037. * @ignorenaming
  29038. */
  29039. DEBUGCANVASSIZE: {
  29040. width: number;
  29041. height: number;
  29042. };
  29043. private _byteFreqs;
  29044. private _byteTime;
  29045. private _floatFreqs;
  29046. private _webAudioAnalyser;
  29047. private _debugCanvas;
  29048. private _debugCanvasContext;
  29049. private _scene;
  29050. private _registerFunc;
  29051. private _audioEngine;
  29052. /**
  29053. * Creates a new analyser
  29054. * @param scene defines hosting scene
  29055. */
  29056. constructor(scene: Scene);
  29057. /**
  29058. * Get the number of data values you will have to play with for the visualization
  29059. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29060. * @returns a number
  29061. */
  29062. getFrequencyBinCount(): number;
  29063. /**
  29064. * Gets the current frequency data as a byte array
  29065. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29066. * @returns a Uint8Array
  29067. */
  29068. getByteFrequencyData(): Uint8Array;
  29069. /**
  29070. * Gets the current waveform as a byte array
  29071. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29072. * @returns a Uint8Array
  29073. */
  29074. getByteTimeDomainData(): Uint8Array;
  29075. /**
  29076. * Gets the current frequency data as a float array
  29077. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29078. * @returns a Float32Array
  29079. */
  29080. getFloatFrequencyData(): Float32Array;
  29081. /**
  29082. * Renders the debug canvas
  29083. */
  29084. drawDebugCanvas(): void;
  29085. /**
  29086. * Stops rendering the debug canvas and removes it
  29087. */
  29088. stopDebugCanvas(): void;
  29089. /**
  29090. * Connects two audio nodes
  29091. * @param inputAudioNode defines first node to connect
  29092. * @param outputAudioNode defines second node to connect
  29093. */
  29094. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29095. /**
  29096. * Releases all associated resources
  29097. */
  29098. dispose(): void;
  29099. }
  29100. }
  29101. declare module BABYLON {
  29102. /**
  29103. * This represents an audio engine and it is responsible
  29104. * to play, synchronize and analyse sounds throughout the application.
  29105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29106. */
  29107. export interface IAudioEngine extends IDisposable {
  29108. /**
  29109. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29110. */
  29111. readonly canUseWebAudio: boolean;
  29112. /**
  29113. * Gets the current AudioContext if available.
  29114. */
  29115. readonly audioContext: Nullable<AudioContext>;
  29116. /**
  29117. * The master gain node defines the global audio volume of your audio engine.
  29118. */
  29119. readonly masterGain: GainNode;
  29120. /**
  29121. * Gets whether or not mp3 are supported by your browser.
  29122. */
  29123. readonly isMP3supported: boolean;
  29124. /**
  29125. * Gets whether or not ogg are supported by your browser.
  29126. */
  29127. readonly isOGGsupported: boolean;
  29128. /**
  29129. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29130. * @ignoreNaming
  29131. */
  29132. WarnedWebAudioUnsupported: boolean;
  29133. /**
  29134. * Defines if the audio engine relies on a custom unlocked button.
  29135. * In this case, the embedded button will not be displayed.
  29136. */
  29137. useCustomUnlockedButton: boolean;
  29138. /**
  29139. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29140. */
  29141. readonly unlocked: boolean;
  29142. /**
  29143. * Event raised when audio has been unlocked on the browser.
  29144. */
  29145. onAudioUnlockedObservable: Observable<AudioEngine>;
  29146. /**
  29147. * Event raised when audio has been locked on the browser.
  29148. */
  29149. onAudioLockedObservable: Observable<AudioEngine>;
  29150. /**
  29151. * Flags the audio engine in Locked state.
  29152. * This happens due to new browser policies preventing audio to autoplay.
  29153. */
  29154. lock(): void;
  29155. /**
  29156. * Unlocks the audio engine once a user action has been done on the dom.
  29157. * This is helpful to resume play once browser policies have been satisfied.
  29158. */
  29159. unlock(): void;
  29160. }
  29161. /**
  29162. * This represents the default audio engine used in babylon.
  29163. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29165. */
  29166. export class AudioEngine implements IAudioEngine {
  29167. private _audioContext;
  29168. private _audioContextInitialized;
  29169. private _muteButton;
  29170. private _hostElement;
  29171. /**
  29172. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29173. */
  29174. canUseWebAudio: boolean;
  29175. /**
  29176. * The master gain node defines the global audio volume of your audio engine.
  29177. */
  29178. masterGain: GainNode;
  29179. /**
  29180. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29181. * @ignoreNaming
  29182. */
  29183. WarnedWebAudioUnsupported: boolean;
  29184. /**
  29185. * Gets whether or not mp3 are supported by your browser.
  29186. */
  29187. isMP3supported: boolean;
  29188. /**
  29189. * Gets whether or not ogg are supported by your browser.
  29190. */
  29191. isOGGsupported: boolean;
  29192. /**
  29193. * Gets whether audio has been unlocked on the device.
  29194. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29195. * a user interaction has happened.
  29196. */
  29197. unlocked: boolean;
  29198. /**
  29199. * Defines if the audio engine relies on a custom unlocked button.
  29200. * In this case, the embedded button will not be displayed.
  29201. */
  29202. useCustomUnlockedButton: boolean;
  29203. /**
  29204. * Event raised when audio has been unlocked on the browser.
  29205. */
  29206. onAudioUnlockedObservable: Observable<AudioEngine>;
  29207. /**
  29208. * Event raised when audio has been locked on the browser.
  29209. */
  29210. onAudioLockedObservable: Observable<AudioEngine>;
  29211. /**
  29212. * Gets the current AudioContext if available.
  29213. */
  29214. readonly audioContext: Nullable<AudioContext>;
  29215. private _connectedAnalyser;
  29216. /**
  29217. * Instantiates a new audio engine.
  29218. *
  29219. * There should be only one per page as some browsers restrict the number
  29220. * of audio contexts you can create.
  29221. * @param hostElement defines the host element where to display the mute icon if necessary
  29222. */
  29223. constructor(hostElement?: Nullable<HTMLElement>);
  29224. /**
  29225. * Flags the audio engine in Locked state.
  29226. * This happens due to new browser policies preventing audio to autoplay.
  29227. */
  29228. lock(): void;
  29229. /**
  29230. * Unlocks the audio engine once a user action has been done on the dom.
  29231. * This is helpful to resume play once browser policies have been satisfied.
  29232. */
  29233. unlock(): void;
  29234. private _resumeAudioContext;
  29235. private _initializeAudioContext;
  29236. private _tryToRun;
  29237. private _triggerRunningState;
  29238. private _triggerSuspendedState;
  29239. private _displayMuteButton;
  29240. private _moveButtonToTopLeft;
  29241. private _onResize;
  29242. private _hideMuteButton;
  29243. /**
  29244. * Destroy and release the resources associated with the audio ccontext.
  29245. */
  29246. dispose(): void;
  29247. /**
  29248. * Gets the global volume sets on the master gain.
  29249. * @returns the global volume if set or -1 otherwise
  29250. */
  29251. getGlobalVolume(): number;
  29252. /**
  29253. * Sets the global volume of your experience (sets on the master gain).
  29254. * @param newVolume Defines the new global volume of the application
  29255. */
  29256. setGlobalVolume(newVolume: number): void;
  29257. /**
  29258. * Connect the audio engine to an audio analyser allowing some amazing
  29259. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29261. * @param analyser The analyser to connect to the engine
  29262. */
  29263. connectToAnalyser(analyser: Analyser): void;
  29264. }
  29265. }
  29266. declare module BABYLON {
  29267. /**
  29268. * Interface used to present a loading screen while loading a scene
  29269. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29270. */
  29271. export interface ILoadingScreen {
  29272. /**
  29273. * Function called to display the loading screen
  29274. */
  29275. displayLoadingUI: () => void;
  29276. /**
  29277. * Function called to hide the loading screen
  29278. */
  29279. hideLoadingUI: () => void;
  29280. /**
  29281. * Gets or sets the color to use for the background
  29282. */
  29283. loadingUIBackgroundColor: string;
  29284. /**
  29285. * Gets or sets the text to display while loading
  29286. */
  29287. loadingUIText: string;
  29288. }
  29289. /**
  29290. * Class used for the default loading screen
  29291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29292. */
  29293. export class DefaultLoadingScreen implements ILoadingScreen {
  29294. private _renderingCanvas;
  29295. private _loadingText;
  29296. private _loadingDivBackgroundColor;
  29297. private _loadingDiv;
  29298. private _loadingTextDiv;
  29299. /** Gets or sets the logo url to use for the default loading screen */
  29300. static DefaultLogoUrl: string;
  29301. /** Gets or sets the spinner url to use for the default loading screen */
  29302. static DefaultSpinnerUrl: string;
  29303. /**
  29304. * Creates a new default loading screen
  29305. * @param _renderingCanvas defines the canvas used to render the scene
  29306. * @param _loadingText defines the default text to display
  29307. * @param _loadingDivBackgroundColor defines the default background color
  29308. */
  29309. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  29310. /**
  29311. * Function called to display the loading screen
  29312. */
  29313. displayLoadingUI(): void;
  29314. /**
  29315. * Function called to hide the loading screen
  29316. */
  29317. hideLoadingUI(): void;
  29318. /**
  29319. * Gets or sets the text to display while loading
  29320. */
  29321. loadingUIText: string;
  29322. /**
  29323. * Gets or sets the color to use for the background
  29324. */
  29325. loadingUIBackgroundColor: string;
  29326. private _resizeLoadingUI;
  29327. }
  29328. }
  29329. declare module BABYLON {
  29330. /** @hidden */
  29331. export class WebGLPipelineContext implements IPipelineContext {
  29332. engine: Engine;
  29333. program: Nullable<WebGLProgram>;
  29334. context?: WebGLRenderingContext;
  29335. vertexShader?: WebGLShader;
  29336. fragmentShader?: WebGLShader;
  29337. isParallelCompiled: boolean;
  29338. onCompiled?: () => void;
  29339. transformFeedback?: WebGLTransformFeedback | null;
  29340. readonly isAsync: boolean;
  29341. readonly isReady: boolean;
  29342. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  29343. }
  29344. }
  29345. declare module BABYLON {
  29346. /** @hidden */
  29347. export class WebGLDataBuffer extends DataBuffer {
  29348. private _buffer;
  29349. constructor(resource: WebGLBuffer);
  29350. readonly underlyingResource: any;
  29351. }
  29352. }
  29353. declare module BABYLON {
  29354. /** @hidden */
  29355. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29356. attributeProcessor(attribute: string): string;
  29357. varyingProcessor(varying: string, isFragment: boolean): string;
  29358. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29359. }
  29360. }
  29361. declare module BABYLON {
  29362. /**
  29363. * This class is used to track a performance counter which is number based.
  29364. * The user has access to many properties which give statistics of different nature.
  29365. *
  29366. * The implementer can track two kinds of Performance Counter: time and count.
  29367. * 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.
  29368. * 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.
  29369. */
  29370. export class PerfCounter {
  29371. /**
  29372. * Gets or sets a global boolean to turn on and off all the counters
  29373. */
  29374. static Enabled: boolean;
  29375. /**
  29376. * Returns the smallest value ever
  29377. */
  29378. readonly min: number;
  29379. /**
  29380. * Returns the biggest value ever
  29381. */
  29382. readonly max: number;
  29383. /**
  29384. * Returns the average value since the performance counter is running
  29385. */
  29386. readonly average: number;
  29387. /**
  29388. * Returns the average value of the last second the counter was monitored
  29389. */
  29390. readonly lastSecAverage: number;
  29391. /**
  29392. * Returns the current value
  29393. */
  29394. readonly current: number;
  29395. /**
  29396. * Gets the accumulated total
  29397. */
  29398. readonly total: number;
  29399. /**
  29400. * Gets the total value count
  29401. */
  29402. readonly count: number;
  29403. /**
  29404. * Creates a new counter
  29405. */
  29406. constructor();
  29407. /**
  29408. * Call this method to start monitoring a new frame.
  29409. * 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.
  29410. */
  29411. fetchNewFrame(): void;
  29412. /**
  29413. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29414. * @param newCount the count value to add to the monitored count
  29415. * @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.
  29416. */
  29417. addCount(newCount: number, fetchResult: boolean): void;
  29418. /**
  29419. * Start monitoring this performance counter
  29420. */
  29421. beginMonitoring(): void;
  29422. /**
  29423. * Compute the time lapsed since the previous beginMonitoring() call.
  29424. * @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
  29425. */
  29426. endMonitoring(newFrame?: boolean): void;
  29427. private _fetchResult;
  29428. private _startMonitoringTime;
  29429. private _min;
  29430. private _max;
  29431. private _average;
  29432. private _current;
  29433. private _totalValueCount;
  29434. private _totalAccumulated;
  29435. private _lastSecAverage;
  29436. private _lastSecAccumulated;
  29437. private _lastSecTime;
  29438. private _lastSecValueCount;
  29439. }
  29440. }
  29441. declare module BABYLON {
  29442. /**
  29443. * Interface for any object that can request an animation frame
  29444. */
  29445. export interface ICustomAnimationFrameRequester {
  29446. /**
  29447. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29448. */
  29449. renderFunction?: Function;
  29450. /**
  29451. * Called to request the next frame to render to
  29452. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29453. */
  29454. requestAnimationFrame: Function;
  29455. /**
  29456. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29457. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29458. */
  29459. requestID?: number;
  29460. }
  29461. }
  29462. declare module BABYLON {
  29463. /**
  29464. * Settings for finer control over video usage
  29465. */
  29466. export interface VideoTextureSettings {
  29467. /**
  29468. * Applies `autoplay` to video, if specified
  29469. */
  29470. autoPlay?: boolean;
  29471. /**
  29472. * Applies `loop` to video, if specified
  29473. */
  29474. loop?: boolean;
  29475. /**
  29476. * Automatically updates internal texture from video at every frame in the render loop
  29477. */
  29478. autoUpdateTexture: boolean;
  29479. /**
  29480. * Image src displayed during the video loading or until the user interacts with the video.
  29481. */
  29482. poster?: string;
  29483. }
  29484. /**
  29485. * If you want to display a video in your scene, this is the special texture for that.
  29486. * This special texture works similar to other textures, with the exception of a few parameters.
  29487. * @see https://doc.babylonjs.com/how_to/video_texture
  29488. */
  29489. export class VideoTexture extends Texture {
  29490. /**
  29491. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29492. */
  29493. readonly autoUpdateTexture: boolean;
  29494. /**
  29495. * The video instance used by the texture internally
  29496. */
  29497. readonly video: HTMLVideoElement;
  29498. private _onUserActionRequestedObservable;
  29499. /**
  29500. * Event triggerd when a dom action is required by the user to play the video.
  29501. * This happens due to recent changes in browser policies preventing video to auto start.
  29502. */
  29503. readonly onUserActionRequestedObservable: Observable<Texture>;
  29504. private _generateMipMaps;
  29505. private _engine;
  29506. private _stillImageCaptured;
  29507. private _displayingPosterTexture;
  29508. private _settings;
  29509. private _createInternalTextureOnEvent;
  29510. private _frameId;
  29511. /**
  29512. * Creates a video texture.
  29513. * If you want to display a video in your scene, this is the special texture for that.
  29514. * This special texture works similar to other textures, with the exception of a few parameters.
  29515. * @see https://doc.babylonjs.com/how_to/video_texture
  29516. * @param name optional name, will detect from video source, if not defined
  29517. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29518. * @param scene is obviously the current scene.
  29519. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29520. * @param invertY is false by default but can be used to invert video on Y axis
  29521. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29522. * @param settings allows finer control over video usage
  29523. */
  29524. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29525. private _getName;
  29526. private _getVideo;
  29527. private _createInternalTexture;
  29528. private reset;
  29529. /**
  29530. * @hidden Internal method to initiate `update`.
  29531. */
  29532. _rebuild(): void;
  29533. /**
  29534. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29535. */
  29536. update(): void;
  29537. /**
  29538. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29539. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29540. */
  29541. updateTexture(isVisible: boolean): void;
  29542. protected _updateInternalTexture: () => void;
  29543. /**
  29544. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29545. * @param url New url.
  29546. */
  29547. updateURL(url: string): void;
  29548. /**
  29549. * Dispose the texture and release its associated resources.
  29550. */
  29551. dispose(): void;
  29552. /**
  29553. * Creates a video texture straight from a stream.
  29554. * @param scene Define the scene the texture should be created in
  29555. * @param stream Define the stream the texture should be created from
  29556. * @returns The created video texture as a promise
  29557. */
  29558. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29559. /**
  29560. * Creates a video texture straight from your WebCam video feed.
  29561. * @param scene Define the scene the texture should be created in
  29562. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29563. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29564. * @returns The created video texture as a promise
  29565. */
  29566. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29567. minWidth: number;
  29568. maxWidth: number;
  29569. minHeight: number;
  29570. maxHeight: number;
  29571. deviceId: string;
  29572. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29573. /**
  29574. * Creates a video texture straight from your WebCam video feed.
  29575. * @param scene Define the scene the texture should be created in
  29576. * @param onReady Define a callback to triggered once the texture will be ready
  29577. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29578. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29579. */
  29580. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29581. minWidth: number;
  29582. maxWidth: number;
  29583. minHeight: number;
  29584. maxHeight: number;
  29585. deviceId: string;
  29586. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29587. }
  29588. }
  29589. declare module BABYLON {
  29590. /**
  29591. * Defines the interface used by objects containing a viewport (like a camera)
  29592. */
  29593. interface IViewportOwnerLike {
  29594. /**
  29595. * Gets or sets the viewport
  29596. */
  29597. viewport: IViewportLike;
  29598. }
  29599. /**
  29600. * Interface for attribute information associated with buffer instanciation
  29601. */
  29602. export class InstancingAttributeInfo {
  29603. /**
  29604. * Index/offset of the attribute in the vertex shader
  29605. */
  29606. index: number;
  29607. /**
  29608. * size of the attribute, 1, 2, 3 or 4
  29609. */
  29610. attributeSize: number;
  29611. /**
  29612. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29613. * default is FLOAT
  29614. */
  29615. attribyteType: number;
  29616. /**
  29617. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29618. */
  29619. normalized: boolean;
  29620. /**
  29621. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29622. */
  29623. offset: number;
  29624. /**
  29625. * Name of the GLSL attribute, for debugging purpose only
  29626. */
  29627. attributeName: string;
  29628. }
  29629. /**
  29630. * Define options used to create a depth texture
  29631. */
  29632. export class DepthTextureCreationOptions {
  29633. /** Specifies whether or not a stencil should be allocated in the texture */
  29634. generateStencil?: boolean;
  29635. /** Specifies whether or not bilinear filtering is enable on the texture */
  29636. bilinearFiltering?: boolean;
  29637. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29638. comparisonFunction?: number;
  29639. /** Specifies if the created texture is a cube texture */
  29640. isCube?: boolean;
  29641. }
  29642. /**
  29643. * Class used to describe the capabilities of the engine relatively to the current browser
  29644. */
  29645. export class EngineCapabilities {
  29646. /** Maximum textures units per fragment shader */
  29647. maxTexturesImageUnits: number;
  29648. /** Maximum texture units per vertex shader */
  29649. maxVertexTextureImageUnits: number;
  29650. /** Maximum textures units in the entire pipeline */
  29651. maxCombinedTexturesImageUnits: number;
  29652. /** Maximum texture size */
  29653. maxTextureSize: number;
  29654. /** Maximum cube texture size */
  29655. maxCubemapTextureSize: number;
  29656. /** Maximum render texture size */
  29657. maxRenderTextureSize: number;
  29658. /** Maximum number of vertex attributes */
  29659. maxVertexAttribs: number;
  29660. /** Maximum number of varyings */
  29661. maxVaryingVectors: number;
  29662. /** Maximum number of uniforms per vertex shader */
  29663. maxVertexUniformVectors: number;
  29664. /** Maximum number of uniforms per fragment shader */
  29665. maxFragmentUniformVectors: number;
  29666. /** Defines if standard derivates (dx/dy) are supported */
  29667. standardDerivatives: boolean;
  29668. /** Defines if s3tc texture compression is supported */
  29669. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29670. /** Defines if pvrtc texture compression is supported */
  29671. pvrtc: any;
  29672. /** Defines if etc1 texture compression is supported */
  29673. etc1: any;
  29674. /** Defines if etc2 texture compression is supported */
  29675. etc2: any;
  29676. /** Defines if astc texture compression is supported */
  29677. astc: any;
  29678. /** Defines if float textures are supported */
  29679. textureFloat: boolean;
  29680. /** Defines if vertex array objects are supported */
  29681. vertexArrayObject: boolean;
  29682. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29683. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29684. /** Gets the maximum level of anisotropy supported */
  29685. maxAnisotropy: number;
  29686. /** Defines if instancing is supported */
  29687. instancedArrays: boolean;
  29688. /** Defines if 32 bits indices are supported */
  29689. uintIndices: boolean;
  29690. /** Defines if high precision shaders are supported */
  29691. highPrecisionShaderSupported: boolean;
  29692. /** Defines if depth reading in the fragment shader is supported */
  29693. fragmentDepthSupported: boolean;
  29694. /** Defines if float texture linear filtering is supported*/
  29695. textureFloatLinearFiltering: boolean;
  29696. /** Defines if rendering to float textures is supported */
  29697. textureFloatRender: boolean;
  29698. /** Defines if half float textures are supported*/
  29699. textureHalfFloat: boolean;
  29700. /** Defines if half float texture linear filtering is supported*/
  29701. textureHalfFloatLinearFiltering: boolean;
  29702. /** Defines if rendering to half float textures is supported */
  29703. textureHalfFloatRender: boolean;
  29704. /** Defines if textureLOD shader command is supported */
  29705. textureLOD: boolean;
  29706. /** Defines if draw buffers extension is supported */
  29707. drawBuffersExtension: boolean;
  29708. /** Defines if depth textures are supported */
  29709. depthTextureExtension: boolean;
  29710. /** Defines if float color buffer are supported */
  29711. colorBufferFloat: boolean;
  29712. /** Gets disjoint timer query extension (null if not supported) */
  29713. timerQuery: EXT_disjoint_timer_query;
  29714. /** Defines if timestamp can be used with timer query */
  29715. canUseTimestampForTimerQuery: boolean;
  29716. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29717. multiview: any;
  29718. /** Function used to let the system compiles shaders in background */
  29719. parallelShaderCompile: {
  29720. COMPLETION_STATUS_KHR: number;
  29721. };
  29722. /** Max number of texture samples for MSAA */
  29723. maxMSAASamples: number;
  29724. }
  29725. /** Interface defining initialization parameters for Engine class */
  29726. export interface EngineOptions extends WebGLContextAttributes {
  29727. /**
  29728. * Defines if the engine should no exceed a specified device ratio
  29729. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29730. */
  29731. limitDeviceRatio?: number;
  29732. /**
  29733. * Defines if webvr should be enabled automatically
  29734. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29735. */
  29736. autoEnableWebVR?: boolean;
  29737. /**
  29738. * Defines if webgl2 should be turned off even if supported
  29739. * @see http://doc.babylonjs.com/features/webgl2
  29740. */
  29741. disableWebGL2Support?: boolean;
  29742. /**
  29743. * Defines if webaudio should be initialized as well
  29744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29745. */
  29746. audioEngine?: boolean;
  29747. /**
  29748. * Defines if animations should run using a deterministic lock step
  29749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29750. */
  29751. deterministicLockstep?: boolean;
  29752. /** Defines the maximum steps to use with deterministic lock step mode */
  29753. lockstepMaxSteps?: number;
  29754. /**
  29755. * Defines that engine should ignore context lost events
  29756. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29757. */
  29758. doNotHandleContextLost?: boolean;
  29759. /**
  29760. * Defines that engine should ignore modifying touch action attribute and style
  29761. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29762. */
  29763. doNotHandleTouchAction?: boolean;
  29764. /**
  29765. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29766. */
  29767. useHighPrecisionFloats?: boolean;
  29768. }
  29769. /**
  29770. * Defines the interface used by display changed events
  29771. */
  29772. export interface IDisplayChangedEventArgs {
  29773. /** Gets the vrDisplay object (if any) */
  29774. vrDisplay: Nullable<any>;
  29775. /** Gets a boolean indicating if webVR is supported */
  29776. vrSupported: boolean;
  29777. }
  29778. /**
  29779. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29780. */
  29781. export class Engine {
  29782. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29783. static ExceptionList: ({
  29784. key: string;
  29785. capture: string;
  29786. captureConstraint: number;
  29787. targets: string[];
  29788. } | {
  29789. key: string;
  29790. capture: null;
  29791. captureConstraint: null;
  29792. targets: string[];
  29793. })[];
  29794. /** Gets the list of created engines */
  29795. static readonly Instances: Engine[];
  29796. /**
  29797. * Gets the latest created engine
  29798. */
  29799. static readonly LastCreatedEngine: Nullable<Engine>;
  29800. /**
  29801. * Gets the latest created scene
  29802. */
  29803. static readonly LastCreatedScene: Nullable<Scene>;
  29804. /**
  29805. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29806. * @param flag defines which part of the materials must be marked as dirty
  29807. * @param predicate defines a predicate used to filter which materials should be affected
  29808. */
  29809. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29810. /** @hidden */
  29811. static _TextureLoaders: IInternalTextureLoader[];
  29812. /** Defines that alpha blending is disabled */
  29813. static readonly ALPHA_DISABLE: number;
  29814. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29815. static readonly ALPHA_ADD: number;
  29816. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29817. static readonly ALPHA_COMBINE: number;
  29818. /** Defines that alpha blending to DEST - SRC * DEST */
  29819. static readonly ALPHA_SUBTRACT: number;
  29820. /** Defines that alpha blending to SRC * DEST */
  29821. static readonly ALPHA_MULTIPLY: number;
  29822. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29823. static readonly ALPHA_MAXIMIZED: number;
  29824. /** Defines that alpha blending to SRC + DEST */
  29825. static readonly ALPHA_ONEONE: number;
  29826. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29827. static readonly ALPHA_PREMULTIPLIED: number;
  29828. /**
  29829. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29830. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29831. */
  29832. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29833. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29834. static readonly ALPHA_INTERPOLATE: number;
  29835. /**
  29836. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29837. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29838. */
  29839. static readonly ALPHA_SCREENMODE: number;
  29840. /** Defines that the ressource is not delayed*/
  29841. static readonly DELAYLOADSTATE_NONE: number;
  29842. /** Defines that the ressource was successfully delay loaded */
  29843. static readonly DELAYLOADSTATE_LOADED: number;
  29844. /** Defines that the ressource is currently delay loading */
  29845. static readonly DELAYLOADSTATE_LOADING: number;
  29846. /** Defines that the ressource is delayed and has not started loading */
  29847. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29849. static readonly NEVER: number;
  29850. /** 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 */
  29851. static readonly ALWAYS: number;
  29852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29853. static readonly LESS: number;
  29854. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29855. static readonly EQUAL: number;
  29856. /** 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 */
  29857. static readonly LEQUAL: number;
  29858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29859. static readonly GREATER: number;
  29860. /** 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 */
  29861. static readonly GEQUAL: number;
  29862. /** 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 */
  29863. static readonly NOTEQUAL: number;
  29864. /** Passed to stencilOperation to specify that stencil value must be kept */
  29865. static readonly KEEP: number;
  29866. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29867. static readonly REPLACE: number;
  29868. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29869. static readonly INCR: number;
  29870. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29871. static readonly DECR: number;
  29872. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29873. static readonly INVERT: number;
  29874. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29875. static readonly INCR_WRAP: number;
  29876. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29877. static readonly DECR_WRAP: number;
  29878. /** Texture is not repeating outside of 0..1 UVs */
  29879. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29880. /** Texture is repeating outside of 0..1 UVs */
  29881. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29882. /** Texture is repeating and mirrored */
  29883. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29884. /** ALPHA */
  29885. static readonly TEXTUREFORMAT_ALPHA: number;
  29886. /** LUMINANCE */
  29887. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29888. /** LUMINANCE_ALPHA */
  29889. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29890. /** RGB */
  29891. static readonly TEXTUREFORMAT_RGB: number;
  29892. /** RGBA */
  29893. static readonly TEXTUREFORMAT_RGBA: number;
  29894. /** RED */
  29895. static readonly TEXTUREFORMAT_RED: number;
  29896. /** RED (2nd reference) */
  29897. static readonly TEXTUREFORMAT_R: number;
  29898. /** RG */
  29899. static readonly TEXTUREFORMAT_RG: number;
  29900. /** RED_INTEGER */
  29901. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29902. /** RED_INTEGER (2nd reference) */
  29903. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29904. /** RG_INTEGER */
  29905. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29906. /** RGB_INTEGER */
  29907. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29908. /** RGBA_INTEGER */
  29909. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29910. /** UNSIGNED_BYTE */
  29911. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29912. /** UNSIGNED_BYTE (2nd reference) */
  29913. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29914. /** FLOAT */
  29915. static readonly TEXTURETYPE_FLOAT: number;
  29916. /** HALF_FLOAT */
  29917. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29918. /** BYTE */
  29919. static readonly TEXTURETYPE_BYTE: number;
  29920. /** SHORT */
  29921. static readonly TEXTURETYPE_SHORT: number;
  29922. /** UNSIGNED_SHORT */
  29923. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29924. /** INT */
  29925. static readonly TEXTURETYPE_INT: number;
  29926. /** UNSIGNED_INT */
  29927. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29928. /** UNSIGNED_SHORT_4_4_4_4 */
  29929. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29930. /** UNSIGNED_SHORT_5_5_5_1 */
  29931. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29932. /** UNSIGNED_SHORT_5_6_5 */
  29933. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29934. /** UNSIGNED_INT_2_10_10_10_REV */
  29935. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29936. /** UNSIGNED_INT_24_8 */
  29937. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29938. /** UNSIGNED_INT_10F_11F_11F_REV */
  29939. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29940. /** UNSIGNED_INT_5_9_9_9_REV */
  29941. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29942. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29943. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29944. /** nearest is mag = nearest and min = nearest and mip = linear */
  29945. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29946. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29947. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29948. /** Trilinear is mag = linear and min = linear and mip = linear */
  29949. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29950. /** nearest is mag = nearest and min = nearest and mip = linear */
  29951. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29952. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29953. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29954. /** Trilinear is mag = linear and min = linear and mip = linear */
  29955. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29956. /** mag = nearest and min = nearest and mip = nearest */
  29957. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29958. /** mag = nearest and min = linear and mip = nearest */
  29959. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29960. /** mag = nearest and min = linear and mip = linear */
  29961. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29962. /** mag = nearest and min = linear and mip = none */
  29963. static readonly TEXTURE_NEAREST_LINEAR: number;
  29964. /** mag = nearest and min = nearest and mip = none */
  29965. static readonly TEXTURE_NEAREST_NEAREST: number;
  29966. /** mag = linear and min = nearest and mip = nearest */
  29967. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29968. /** mag = linear and min = nearest and mip = linear */
  29969. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29970. /** mag = linear and min = linear and mip = none */
  29971. static readonly TEXTURE_LINEAR_LINEAR: number;
  29972. /** mag = linear and min = nearest and mip = none */
  29973. static readonly TEXTURE_LINEAR_NEAREST: number;
  29974. /** Explicit coordinates mode */
  29975. static readonly TEXTURE_EXPLICIT_MODE: number;
  29976. /** Spherical coordinates mode */
  29977. static readonly TEXTURE_SPHERICAL_MODE: number;
  29978. /** Planar coordinates mode */
  29979. static readonly TEXTURE_PLANAR_MODE: number;
  29980. /** Cubic coordinates mode */
  29981. static readonly TEXTURE_CUBIC_MODE: number;
  29982. /** Projection coordinates mode */
  29983. static readonly TEXTURE_PROJECTION_MODE: number;
  29984. /** Skybox coordinates mode */
  29985. static readonly TEXTURE_SKYBOX_MODE: number;
  29986. /** Inverse Cubic coordinates mode */
  29987. static readonly TEXTURE_INVCUBIC_MODE: number;
  29988. /** Equirectangular coordinates mode */
  29989. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29990. /** Equirectangular Fixed coordinates mode */
  29991. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29992. /** Equirectangular Fixed Mirrored coordinates mode */
  29993. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29994. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29995. static readonly SCALEMODE_FLOOR: number;
  29996. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29997. static readonly SCALEMODE_NEAREST: number;
  29998. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29999. static readonly SCALEMODE_CEILING: number;
  30000. /**
  30001. * Returns the current npm package of the sdk
  30002. */
  30003. static readonly NpmPackage: string;
  30004. /**
  30005. * Returns the current version of the framework
  30006. */
  30007. static readonly Version: string;
  30008. /**
  30009. * Returns a string describing the current engine
  30010. */
  30011. readonly description: string;
  30012. /**
  30013. * Gets or sets the epsilon value used by collision engine
  30014. */
  30015. static CollisionsEpsilon: number;
  30016. /**
  30017. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30018. */
  30019. static ShadersRepository: string;
  30020. /**
  30021. * Method called to create the default loading screen.
  30022. * This can be overriden in your own app.
  30023. * @param canvas The rendering canvas element
  30024. * @returns The loading screen
  30025. */
  30026. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30027. /**
  30028. * Method called to create the default rescale post process on each engine.
  30029. */
  30030. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30031. /** @hidden */
  30032. _shaderProcessor: IShaderProcessor;
  30033. /**
  30034. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30035. */
  30036. forcePOTTextures: boolean;
  30037. /**
  30038. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30039. */
  30040. isFullscreen: boolean;
  30041. /**
  30042. * Gets a boolean indicating if the pointer is currently locked
  30043. */
  30044. isPointerLock: boolean;
  30045. /**
  30046. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30047. */
  30048. cullBackFaces: boolean;
  30049. /**
  30050. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30051. */
  30052. renderEvenInBackground: boolean;
  30053. /**
  30054. * Gets or sets a boolean indicating that cache can be kept between frames
  30055. */
  30056. preventCacheWipeBetweenFrames: boolean;
  30057. /**
  30058. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30059. **/
  30060. enableOfflineSupport: boolean;
  30061. /**
  30062. * 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)
  30063. **/
  30064. disableManifestCheck: boolean;
  30065. /**
  30066. * Gets the list of created scenes
  30067. */
  30068. scenes: Scene[];
  30069. /**
  30070. * Event raised when a new scene is created
  30071. */
  30072. onNewSceneAddedObservable: Observable<Scene>;
  30073. /**
  30074. * Gets the list of created postprocesses
  30075. */
  30076. postProcesses: PostProcess[];
  30077. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30078. validateShaderPrograms: boolean;
  30079. /**
  30080. * Observable event triggered each time the rendering canvas is resized
  30081. */
  30082. onResizeObservable: Observable<Engine>;
  30083. /**
  30084. * Observable event triggered each time the canvas loses focus
  30085. */
  30086. onCanvasBlurObservable: Observable<Engine>;
  30087. /**
  30088. * Observable event triggered each time the canvas gains focus
  30089. */
  30090. onCanvasFocusObservable: Observable<Engine>;
  30091. /**
  30092. * Observable event triggered each time the canvas receives pointerout event
  30093. */
  30094. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30095. /**
  30096. * Observable event triggered before each texture is initialized
  30097. */
  30098. onBeforeTextureInitObservable: Observable<Texture>;
  30099. /**
  30100. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30101. */
  30102. disableUniformBuffers: boolean;
  30103. /** @hidden */
  30104. _uniformBuffers: UniformBuffer[];
  30105. /**
  30106. * Gets a boolean indicating that the engine supports uniform buffers
  30107. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30108. */
  30109. readonly supportsUniformBuffers: boolean;
  30110. /**
  30111. * Observable raised when the engine begins a new frame
  30112. */
  30113. onBeginFrameObservable: Observable<Engine>;
  30114. /**
  30115. * If set, will be used to request the next animation frame for the render loop
  30116. */
  30117. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30118. /**
  30119. * Observable raised when the engine ends the current frame
  30120. */
  30121. onEndFrameObservable: Observable<Engine>;
  30122. /**
  30123. * Observable raised when the engine is about to compile a shader
  30124. */
  30125. onBeforeShaderCompilationObservable: Observable<Engine>;
  30126. /**
  30127. * Observable raised when the engine has jsut compiled a shader
  30128. */
  30129. onAfterShaderCompilationObservable: Observable<Engine>;
  30130. /** @hidden */
  30131. _gl: WebGLRenderingContext;
  30132. private _renderingCanvas;
  30133. private _windowIsBackground;
  30134. protected _webGLVersion: number;
  30135. protected _highPrecisionShadersAllowed: boolean;
  30136. /** @hidden */
  30137. readonly _shouldUseHighPrecisionShader: boolean;
  30138. /**
  30139. * Gets a boolean indicating that only power of 2 textures are supported
  30140. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30141. */
  30142. readonly needPOTTextures: boolean;
  30143. /** @hidden */
  30144. _badOS: boolean;
  30145. /** @hidden */
  30146. _badDesktopOS: boolean;
  30147. /**
  30148. * Gets the audio engine
  30149. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30150. * @ignorenaming
  30151. */
  30152. static audioEngine: IAudioEngine;
  30153. /**
  30154. * Default AudioEngine factory responsible of creating the Audio Engine.
  30155. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30156. */
  30157. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30158. /**
  30159. * Default offline support factory responsible of creating a tool used to store data locally.
  30160. * By default, this will create a Database object if the workload has been embedded.
  30161. */
  30162. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30163. private _onFocus;
  30164. private _onBlur;
  30165. private _onCanvasPointerOut;
  30166. private _onCanvasBlur;
  30167. private _onCanvasFocus;
  30168. private _onFullscreenChange;
  30169. private _onPointerLockChange;
  30170. private _hardwareScalingLevel;
  30171. /** @hidden */
  30172. _caps: EngineCapabilities;
  30173. private _pointerLockRequested;
  30174. private _isStencilEnable;
  30175. protected _colorWrite: boolean;
  30176. private _loadingScreen;
  30177. /** @hidden */
  30178. _drawCalls: PerfCounter;
  30179. private _glVersion;
  30180. private _glRenderer;
  30181. private _glVendor;
  30182. private _videoTextureSupported;
  30183. private _renderingQueueLaunched;
  30184. private _activeRenderLoops;
  30185. private _deterministicLockstep;
  30186. private _lockstepMaxSteps;
  30187. /**
  30188. * Observable signaled when a context lost event is raised
  30189. */
  30190. onContextLostObservable: Observable<Engine>;
  30191. /**
  30192. * Observable signaled when a context restored event is raised
  30193. */
  30194. onContextRestoredObservable: Observable<Engine>;
  30195. private _onContextLost;
  30196. private _onContextRestored;
  30197. private _contextWasLost;
  30198. /** @hidden */
  30199. _doNotHandleContextLost: boolean;
  30200. /**
  30201. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30203. */
  30204. doNotHandleContextLost: boolean;
  30205. private _performanceMonitor;
  30206. private _fps;
  30207. private _deltaTime;
  30208. /**
  30209. * Turn this value on if you want to pause FPS computation when in background
  30210. */
  30211. disablePerformanceMonitorInBackground: boolean;
  30212. /**
  30213. * Gets the performance monitor attached to this engine
  30214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30215. */
  30216. readonly performanceMonitor: PerformanceMonitor;
  30217. /**
  30218. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30219. */
  30220. disableVertexArrayObjects: boolean;
  30221. /** @hidden */
  30222. protected _depthCullingState: _DepthCullingState;
  30223. /** @hidden */
  30224. protected _stencilState: _StencilState;
  30225. /** @hidden */
  30226. protected _alphaState: _AlphaState;
  30227. /** @hidden */
  30228. protected _alphaMode: number;
  30229. /** @hidden */
  30230. _internalTexturesCache: InternalTexture[];
  30231. /** @hidden */
  30232. protected _activeChannel: number;
  30233. private _currentTextureChannel;
  30234. /** @hidden */
  30235. protected _boundTexturesCache: {
  30236. [key: string]: Nullable<InternalTexture>;
  30237. };
  30238. /** @hidden */
  30239. protected _currentEffect: Nullable<Effect>;
  30240. /** @hidden */
  30241. protected _currentProgram: Nullable<WebGLProgram>;
  30242. private _compiledEffects;
  30243. private _vertexAttribArraysEnabled;
  30244. /** @hidden */
  30245. protected _cachedViewport: Nullable<IViewportLike>;
  30246. private _cachedVertexArrayObject;
  30247. /** @hidden */
  30248. protected _cachedVertexBuffers: any;
  30249. /** @hidden */
  30250. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30251. /** @hidden */
  30252. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30253. /** @hidden */
  30254. _currentRenderTarget: Nullable<InternalTexture>;
  30255. private _uintIndicesCurrentlySet;
  30256. private _currentBoundBuffer;
  30257. /** @hidden */
  30258. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30259. private _currentBufferPointers;
  30260. private _currentInstanceLocations;
  30261. private _currentInstanceBuffers;
  30262. private _textureUnits;
  30263. /** @hidden */
  30264. _workingCanvas: Nullable<HTMLCanvasElement>;
  30265. /** @hidden */
  30266. _workingContext: Nullable<CanvasRenderingContext2D>;
  30267. private _rescalePostProcess;
  30268. private _dummyFramebuffer;
  30269. private _externalData;
  30270. /** @hidden */
  30271. _bindedRenderFunction: any;
  30272. private _vaoRecordInProgress;
  30273. private _mustWipeVertexAttributes;
  30274. private _emptyTexture;
  30275. private _emptyCubeTexture;
  30276. private _emptyTexture3D;
  30277. /** @hidden */
  30278. _frameHandler: number;
  30279. private _nextFreeTextureSlots;
  30280. private _maxSimultaneousTextures;
  30281. private _activeRequests;
  30282. private _texturesSupported;
  30283. /** @hidden */
  30284. _textureFormatInUse: Nullable<string>;
  30285. /**
  30286. * Gets the list of texture formats supported
  30287. */
  30288. readonly texturesSupported: Array<string>;
  30289. /**
  30290. * Gets the list of texture formats in use
  30291. */
  30292. readonly textureFormatInUse: Nullable<string>;
  30293. /**
  30294. * Gets the current viewport
  30295. */
  30296. readonly currentViewport: Nullable<IViewportLike>;
  30297. /**
  30298. * Gets the default empty texture
  30299. */
  30300. readonly emptyTexture: InternalTexture;
  30301. /**
  30302. * Gets the default empty 3D texture
  30303. */
  30304. readonly emptyTexture3D: InternalTexture;
  30305. /**
  30306. * Gets the default empty cube texture
  30307. */
  30308. readonly emptyCubeTexture: InternalTexture;
  30309. /**
  30310. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30311. */
  30312. readonly premultipliedAlpha: boolean;
  30313. /**
  30314. * Creates a new engine
  30315. * @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
  30316. * @param antialias defines enable antialiasing (default: false)
  30317. * @param options defines further options to be sent to the getContext() function
  30318. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30319. */
  30320. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30321. /**
  30322. * Initializes a webVR display and starts listening to display change events
  30323. * The onVRDisplayChangedObservable will be notified upon these changes
  30324. * @returns The onVRDisplayChangedObservable
  30325. */
  30326. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30327. /** @hidden */
  30328. _prepareVRComponent(): void;
  30329. /** @hidden */
  30330. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30331. /** @hidden */
  30332. _submitVRFrame(): void;
  30333. /**
  30334. * Call this function to leave webVR mode
  30335. * Will do nothing if webVR is not supported or if there is no webVR device
  30336. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30337. */
  30338. disableVR(): void;
  30339. /**
  30340. * Gets a boolean indicating that the system is in VR mode and is presenting
  30341. * @returns true if VR mode is engaged
  30342. */
  30343. isVRPresenting(): boolean;
  30344. /** @hidden */
  30345. _requestVRFrame(): void;
  30346. private _disableTouchAction;
  30347. private _rebuildInternalTextures;
  30348. private _rebuildEffects;
  30349. /**
  30350. * Gets a boolean indicating if all created effects are ready
  30351. * @returns true if all effects are ready
  30352. */
  30353. areAllEffectsReady(): boolean;
  30354. private _rebuildBuffers;
  30355. private _initGLContext;
  30356. /**
  30357. * Gets version of the current webGL context
  30358. */
  30359. readonly webGLVersion: number;
  30360. /**
  30361. * Gets a string idenfifying the name of the class
  30362. * @returns "Engine" string
  30363. */
  30364. getClassName(): string;
  30365. /**
  30366. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30367. */
  30368. readonly isStencilEnable: boolean;
  30369. /** @hidden */
  30370. _prepareWorkingCanvas(): void;
  30371. /**
  30372. * Reset the texture cache to empty state
  30373. */
  30374. resetTextureCache(): void;
  30375. /**
  30376. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30377. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30378. * @returns true if engine is in deterministic lock step mode
  30379. */
  30380. isDeterministicLockStep(): boolean;
  30381. /**
  30382. * Gets the max steps when engine is running in deterministic lock step
  30383. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30384. * @returns the max steps
  30385. */
  30386. getLockstepMaxSteps(): number;
  30387. /**
  30388. * Gets an object containing information about the current webGL context
  30389. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30390. */
  30391. getGlInfo(): {
  30392. vendor: string;
  30393. renderer: string;
  30394. version: string;
  30395. };
  30396. /**
  30397. * Gets current aspect ratio
  30398. * @param viewportOwner defines the camera to use to get the aspect ratio
  30399. * @param useScreen defines if screen size must be used (or the current render target if any)
  30400. * @returns a number defining the aspect ratio
  30401. */
  30402. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30403. /**
  30404. * Gets current screen aspect ratio
  30405. * @returns a number defining the aspect ratio
  30406. */
  30407. getScreenAspectRatio(): number;
  30408. /**
  30409. * Gets the current render width
  30410. * @param useScreen defines if screen size must be used (or the current render target if any)
  30411. * @returns a number defining the current render width
  30412. */
  30413. getRenderWidth(useScreen?: boolean): number;
  30414. /**
  30415. * Gets the current render height
  30416. * @param useScreen defines if screen size must be used (or the current render target if any)
  30417. * @returns a number defining the current render height
  30418. */
  30419. getRenderHeight(useScreen?: boolean): number;
  30420. /**
  30421. * Gets the HTML canvas attached with the current webGL context
  30422. * @returns a HTML canvas
  30423. */
  30424. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30425. /**
  30426. * Gets host window
  30427. * @returns the host window object
  30428. */
  30429. getHostWindow(): Window;
  30430. /**
  30431. * Gets host document
  30432. * @returns the host document object
  30433. */
  30434. getHostDocument(): Document;
  30435. /**
  30436. * Gets the client rect of the HTML canvas attached with the current webGL context
  30437. * @returns a client rectanglee
  30438. */
  30439. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30440. /**
  30441. * Defines the hardware scaling level.
  30442. * By default the hardware scaling level is computed from the window device ratio.
  30443. * 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.
  30444. * @param level defines the level to use
  30445. */
  30446. setHardwareScalingLevel(level: number): void;
  30447. /**
  30448. * Gets the current hardware scaling level.
  30449. * By default the hardware scaling level is computed from the window device ratio.
  30450. * 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.
  30451. * @returns a number indicating the current hardware scaling level
  30452. */
  30453. getHardwareScalingLevel(): number;
  30454. /**
  30455. * Gets the list of loaded textures
  30456. * @returns an array containing all loaded textures
  30457. */
  30458. getLoadedTexturesCache(): InternalTexture[];
  30459. /**
  30460. * Gets the object containing all engine capabilities
  30461. * @returns the EngineCapabilities object
  30462. */
  30463. getCaps(): EngineCapabilities;
  30464. /**
  30465. * Gets the current depth function
  30466. * @returns a number defining the depth function
  30467. */
  30468. getDepthFunction(): Nullable<number>;
  30469. /**
  30470. * Sets the current depth function
  30471. * @param depthFunc defines the function to use
  30472. */
  30473. setDepthFunction(depthFunc: number): void;
  30474. /**
  30475. * Sets the current depth function to GREATER
  30476. */
  30477. setDepthFunctionToGreater(): void;
  30478. /**
  30479. * Sets the current depth function to GEQUAL
  30480. */
  30481. setDepthFunctionToGreaterOrEqual(): void;
  30482. /**
  30483. * Sets the current depth function to LESS
  30484. */
  30485. setDepthFunctionToLess(): void;
  30486. private _cachedStencilBuffer;
  30487. private _cachedStencilFunction;
  30488. private _cachedStencilMask;
  30489. private _cachedStencilOperationPass;
  30490. private _cachedStencilOperationFail;
  30491. private _cachedStencilOperationDepthFail;
  30492. private _cachedStencilReference;
  30493. /**
  30494. * Caches the the state of the stencil buffer
  30495. */
  30496. cacheStencilState(): void;
  30497. /**
  30498. * Restores the state of the stencil buffer
  30499. */
  30500. restoreStencilState(): void;
  30501. /**
  30502. * Sets the current depth function to LEQUAL
  30503. */
  30504. setDepthFunctionToLessOrEqual(): void;
  30505. /**
  30506. * Gets a boolean indicating if stencil buffer is enabled
  30507. * @returns the current stencil buffer state
  30508. */
  30509. getStencilBuffer(): boolean;
  30510. /**
  30511. * Enable or disable the stencil buffer
  30512. * @param enable defines if the stencil buffer must be enabled or disabled
  30513. */
  30514. setStencilBuffer(enable: boolean): void;
  30515. /**
  30516. * Gets the current stencil mask
  30517. * @returns a number defining the new stencil mask to use
  30518. */
  30519. getStencilMask(): number;
  30520. /**
  30521. * Sets the current stencil mask
  30522. * @param mask defines the new stencil mask to use
  30523. */
  30524. setStencilMask(mask: number): void;
  30525. /**
  30526. * Gets the current stencil function
  30527. * @returns a number defining the stencil function to use
  30528. */
  30529. getStencilFunction(): number;
  30530. /**
  30531. * Gets the current stencil reference value
  30532. * @returns a number defining the stencil reference value to use
  30533. */
  30534. getStencilFunctionReference(): number;
  30535. /**
  30536. * Gets the current stencil mask
  30537. * @returns a number defining the stencil mask to use
  30538. */
  30539. getStencilFunctionMask(): number;
  30540. /**
  30541. * Sets the current stencil function
  30542. * @param stencilFunc defines the new stencil function to use
  30543. */
  30544. setStencilFunction(stencilFunc: number): void;
  30545. /**
  30546. * Sets the current stencil reference
  30547. * @param reference defines the new stencil reference to use
  30548. */
  30549. setStencilFunctionReference(reference: number): void;
  30550. /**
  30551. * Sets the current stencil mask
  30552. * @param mask defines the new stencil mask to use
  30553. */
  30554. setStencilFunctionMask(mask: number): void;
  30555. /**
  30556. * Gets the current stencil operation when stencil fails
  30557. * @returns a number defining stencil operation to use when stencil fails
  30558. */
  30559. getStencilOperationFail(): number;
  30560. /**
  30561. * Gets the current stencil operation when depth fails
  30562. * @returns a number defining stencil operation to use when depth fails
  30563. */
  30564. getStencilOperationDepthFail(): number;
  30565. /**
  30566. * Gets the current stencil operation when stencil passes
  30567. * @returns a number defining stencil operation to use when stencil passes
  30568. */
  30569. getStencilOperationPass(): number;
  30570. /**
  30571. * Sets the stencil operation to use when stencil fails
  30572. * @param operation defines the stencil operation to use when stencil fails
  30573. */
  30574. setStencilOperationFail(operation: number): void;
  30575. /**
  30576. * Sets the stencil operation to use when depth fails
  30577. * @param operation defines the stencil operation to use when depth fails
  30578. */
  30579. setStencilOperationDepthFail(operation: number): void;
  30580. /**
  30581. * Sets the stencil operation to use when stencil passes
  30582. * @param operation defines the stencil operation to use when stencil passes
  30583. */
  30584. setStencilOperationPass(operation: number): void;
  30585. /**
  30586. * Sets a boolean indicating if the dithering state is enabled or disabled
  30587. * @param value defines the dithering state
  30588. */
  30589. setDitheringState(value: boolean): void;
  30590. /**
  30591. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30592. * @param value defines the rasterizer state
  30593. */
  30594. setRasterizerState(value: boolean): void;
  30595. /**
  30596. * stop executing a render loop function and remove it from the execution array
  30597. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30598. */
  30599. stopRenderLoop(renderFunction?: () => void): void;
  30600. /** @hidden */
  30601. _renderLoop(): void;
  30602. /**
  30603. * Can be used to override the current requestAnimationFrame requester.
  30604. * @hidden
  30605. */
  30606. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30607. /**
  30608. * Register and execute a render loop. The engine can have more than one render function
  30609. * @param renderFunction defines the function to continuously execute
  30610. */
  30611. runRenderLoop(renderFunction: () => void): void;
  30612. /**
  30613. * Toggle full screen mode
  30614. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30615. */
  30616. switchFullscreen(requestPointerLock: boolean): void;
  30617. /**
  30618. * Enters full screen mode
  30619. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30620. */
  30621. enterFullscreen(requestPointerLock: boolean): void;
  30622. /**
  30623. * Exits full screen mode
  30624. */
  30625. exitFullscreen(): void;
  30626. /**
  30627. * Enters Pointerlock mode
  30628. */
  30629. enterPointerlock(): void;
  30630. /**
  30631. * Exits Pointerlock mode
  30632. */
  30633. exitPointerlock(): void;
  30634. /**
  30635. * Clear the current render buffer or the current render target (if any is set up)
  30636. * @param color defines the color to use
  30637. * @param backBuffer defines if the back buffer must be cleared
  30638. * @param depth defines if the depth buffer must be cleared
  30639. * @param stencil defines if the stencil buffer must be cleared
  30640. */
  30641. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30642. /**
  30643. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30644. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30645. * @param y defines the y-coordinate of the corner of the clear rectangle
  30646. * @param width defines the width of the clear rectangle
  30647. * @param height defines the height of the clear rectangle
  30648. * @param clearColor defines the clear color
  30649. */
  30650. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30651. /**
  30652. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30653. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30654. * @param y defines the y-coordinate of the corner of the clear rectangle
  30655. * @param width defines the width of the clear rectangle
  30656. * @param height defines the height of the clear rectangle
  30657. */
  30658. enableScissor(x: number, y: number, width: number, height: number): void;
  30659. /**
  30660. * Disable previously set scissor test rectangle
  30661. */
  30662. disableScissor(): void;
  30663. private _viewportCached;
  30664. /** @hidden */
  30665. _viewport(x: number, y: number, width: number, height: number): void;
  30666. /**
  30667. * Set the WebGL's viewport
  30668. * @param viewport defines the viewport element to be used
  30669. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30670. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30671. */
  30672. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30673. /**
  30674. * Directly set the WebGL Viewport
  30675. * @param x defines the x coordinate of the viewport (in screen space)
  30676. * @param y defines the y coordinate of the viewport (in screen space)
  30677. * @param width defines the width of the viewport (in screen space)
  30678. * @param height defines the height of the viewport (in screen space)
  30679. * @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
  30680. */
  30681. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30682. /**
  30683. * Begin a new frame
  30684. */
  30685. beginFrame(): void;
  30686. /**
  30687. * Enf the current frame
  30688. */
  30689. endFrame(): void;
  30690. /**
  30691. * Resize the view according to the canvas' size
  30692. */
  30693. resize(): void;
  30694. /**
  30695. * Force a specific size of the canvas
  30696. * @param width defines the new canvas' width
  30697. * @param height defines the new canvas' height
  30698. */
  30699. setSize(width: number, height: number): void;
  30700. /**
  30701. * Binds the frame buffer to the specified texture.
  30702. * @param texture The texture to render to or null for the default canvas
  30703. * @param faceIndex The face of the texture to render to in case of cube texture
  30704. * @param requiredWidth The width of the target to render to
  30705. * @param requiredHeight The height of the target to render to
  30706. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30707. * @param depthStencilTexture The depth stencil texture to use to render
  30708. * @param lodLevel defines le lod level to bind to the frame buffer
  30709. */
  30710. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30711. /** @hidden */
  30712. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30713. /**
  30714. * Unbind the current render target texture from the webGL context
  30715. * @param texture defines the render target texture to unbind
  30716. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30717. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30718. */
  30719. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30720. /**
  30721. * Force the mipmap generation for the given render target texture
  30722. * @param texture defines the render target texture to use
  30723. */
  30724. generateMipMapsForCubemap(texture: InternalTexture): void;
  30725. /**
  30726. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30727. */
  30728. flushFramebuffer(): void;
  30729. /**
  30730. * Unbind the current render target and bind the default framebuffer
  30731. */
  30732. restoreDefaultFramebuffer(): void;
  30733. /**
  30734. * Create an uniform buffer
  30735. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30736. * @param elements defines the content of the uniform buffer
  30737. * @returns the webGL uniform buffer
  30738. */
  30739. createUniformBuffer(elements: FloatArray): DataBuffer;
  30740. /**
  30741. * Create a dynamic uniform buffer
  30742. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30743. * @param elements defines the content of the uniform buffer
  30744. * @returns the webGL uniform buffer
  30745. */
  30746. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30747. /**
  30748. * Update an existing uniform buffer
  30749. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30750. * @param uniformBuffer defines the target uniform buffer
  30751. * @param elements defines the content to update
  30752. * @param offset defines the offset in the uniform buffer where update should start
  30753. * @param count defines the size of the data to update
  30754. */
  30755. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30756. private _resetVertexBufferBinding;
  30757. /**
  30758. * Creates a vertex buffer
  30759. * @param data the data for the vertex buffer
  30760. * @returns the new WebGL static buffer
  30761. */
  30762. createVertexBuffer(data: DataArray): DataBuffer;
  30763. /**
  30764. * Creates a dynamic vertex buffer
  30765. * @param data the data for the dynamic vertex buffer
  30766. * @returns the new WebGL dynamic buffer
  30767. */
  30768. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30769. /**
  30770. * Update a dynamic index buffer
  30771. * @param indexBuffer defines the target index buffer
  30772. * @param indices defines the data to update
  30773. * @param offset defines the offset in the target index buffer where update should start
  30774. */
  30775. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30776. /**
  30777. * Updates a dynamic vertex buffer.
  30778. * @param vertexBuffer the vertex buffer to update
  30779. * @param data the data used to update the vertex buffer
  30780. * @param byteOffset the byte offset of the data
  30781. * @param byteLength the byte length of the data
  30782. */
  30783. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30784. private _resetIndexBufferBinding;
  30785. /**
  30786. * Creates a new index buffer
  30787. * @param indices defines the content of the index buffer
  30788. * @param updatable defines if the index buffer must be updatable
  30789. * @returns a new webGL buffer
  30790. */
  30791. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30792. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30793. /**
  30794. * Bind a webGL buffer to the webGL context
  30795. * @param buffer defines the buffer to bind
  30796. */
  30797. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30798. /**
  30799. * Bind an uniform buffer to the current webGL context
  30800. * @param buffer defines the buffer to bind
  30801. */
  30802. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30803. /**
  30804. * Bind a buffer to the current webGL context at a given location
  30805. * @param buffer defines the buffer to bind
  30806. * @param location defines the index where to bind the buffer
  30807. */
  30808. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30809. /**
  30810. * Bind a specific block at a given index in a specific shader program
  30811. * @param pipelineContext defines the pipeline context to use
  30812. * @param blockName defines the block name
  30813. * @param index defines the index where to bind the block
  30814. */
  30815. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30816. private bindIndexBuffer;
  30817. private bindBuffer;
  30818. /**
  30819. * update the bound buffer with the given data
  30820. * @param data defines the data to update
  30821. */
  30822. updateArrayBuffer(data: Float32Array): void;
  30823. private _vertexAttribPointer;
  30824. private _bindIndexBufferWithCache;
  30825. private _bindVertexBuffersAttributes;
  30826. /**
  30827. * Records a vertex array object
  30828. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30829. * @param vertexBuffers defines the list of vertex buffers to store
  30830. * @param indexBuffer defines the index buffer to store
  30831. * @param effect defines the effect to store
  30832. * @returns the new vertex array object
  30833. */
  30834. recordVertexArrayObject(vertexBuffers: {
  30835. [key: string]: VertexBuffer;
  30836. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30837. /**
  30838. * Bind a specific vertex array object
  30839. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30840. * @param vertexArrayObject defines the vertex array object to bind
  30841. * @param indexBuffer defines the index buffer to bind
  30842. */
  30843. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30844. /**
  30845. * Bind webGl buffers directly to the webGL context
  30846. * @param vertexBuffer defines the vertex buffer to bind
  30847. * @param indexBuffer defines the index buffer to bind
  30848. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30849. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30850. * @param effect defines the effect associated with the vertex buffer
  30851. */
  30852. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30853. private _unbindVertexArrayObject;
  30854. /**
  30855. * Bind a list of vertex buffers to the webGL context
  30856. * @param vertexBuffers defines the list of vertex buffers to bind
  30857. * @param indexBuffer defines the index buffer to bind
  30858. * @param effect defines the effect associated with the vertex buffers
  30859. */
  30860. bindBuffers(vertexBuffers: {
  30861. [key: string]: Nullable<VertexBuffer>;
  30862. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30863. /**
  30864. * Unbind all instance attributes
  30865. */
  30866. unbindInstanceAttributes(): void;
  30867. /**
  30868. * Release and free the memory of a vertex array object
  30869. * @param vao defines the vertex array object to delete
  30870. */
  30871. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30872. /** @hidden */
  30873. _releaseBuffer(buffer: DataBuffer): boolean;
  30874. protected _deleteBuffer(buffer: DataBuffer): void;
  30875. /**
  30876. * Creates a webGL buffer to use with instanciation
  30877. * @param capacity defines the size of the buffer
  30878. * @returns the webGL buffer
  30879. */
  30880. createInstancesBuffer(capacity: number): DataBuffer;
  30881. /**
  30882. * Delete a webGL buffer used with instanciation
  30883. * @param buffer defines the webGL buffer to delete
  30884. */
  30885. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30886. /**
  30887. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30888. * @param instancesBuffer defines the webGL buffer to update and bind
  30889. * @param data defines the data to store in the buffer
  30890. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30891. */
  30892. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30893. /**
  30894. * Apply all cached states (depth, culling, stencil and alpha)
  30895. */
  30896. applyStates(): void;
  30897. /**
  30898. * Send a draw order
  30899. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30900. * @param indexStart defines the starting index
  30901. * @param indexCount defines the number of index to draw
  30902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30903. */
  30904. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30905. /**
  30906. * Draw a list of points
  30907. * @param verticesStart defines the index of first vertex to draw
  30908. * @param verticesCount defines the count of vertices to draw
  30909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30910. */
  30911. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30912. /**
  30913. * Draw a list of unindexed primitives
  30914. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30915. * @param verticesStart defines the index of first vertex to draw
  30916. * @param verticesCount defines the count of vertices to draw
  30917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30918. */
  30919. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30920. /**
  30921. * Draw a list of indexed primitives
  30922. * @param fillMode defines the primitive to use
  30923. * @param indexStart defines the starting index
  30924. * @param indexCount defines the number of index to draw
  30925. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30926. */
  30927. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30928. /**
  30929. * Draw a list of unindexed primitives
  30930. * @param fillMode defines the primitive to use
  30931. * @param verticesStart defines the index of first vertex to draw
  30932. * @param verticesCount defines the count of vertices to draw
  30933. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30934. */
  30935. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30936. private _drawMode;
  30937. /** @hidden */
  30938. _releaseEffect(effect: Effect): void;
  30939. /** @hidden */
  30940. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30941. /**
  30942. * Create a new effect (used to store vertex/fragment shaders)
  30943. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30944. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30945. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30946. * @param samplers defines an array of string used to represent textures
  30947. * @param defines defines the string containing the defines to use to compile the shaders
  30948. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30949. * @param onCompiled defines a function to call when the effect creation is successful
  30950. * @param onError defines a function to call when the effect creation has failed
  30951. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30952. * @returns the new Effect
  30953. */
  30954. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30955. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30956. private _compileShader;
  30957. private _compileRawShader;
  30958. /**
  30959. * Directly creates a webGL program
  30960. * @param pipelineContext defines the pipeline context to attach to
  30961. * @param vertexCode defines the vertex shader code to use
  30962. * @param fragmentCode defines the fragment shader code to use
  30963. * @param context defines the webGL context to use (if not set, the current one will be used)
  30964. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30965. * @returns the new webGL program
  30966. */
  30967. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30968. /**
  30969. * Creates a webGL program
  30970. * @param pipelineContext defines the pipeline context to attach to
  30971. * @param vertexCode defines the vertex shader code to use
  30972. * @param fragmentCode defines the fragment shader code to use
  30973. * @param defines defines the string containing the defines to use to compile the shaders
  30974. * @param context defines the webGL context to use (if not set, the current one will be used)
  30975. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30976. * @returns the new webGL program
  30977. */
  30978. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30979. /**
  30980. * Creates a new pipeline context
  30981. * @returns the new pipeline
  30982. */
  30983. createPipelineContext(): IPipelineContext;
  30984. private _createShaderProgram;
  30985. private _finalizePipelineContext;
  30986. /** @hidden */
  30987. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30988. /** @hidden */
  30989. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30990. /** @hidden */
  30991. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30992. /**
  30993. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30994. * @param pipelineContext defines the pipeline context to use
  30995. * @param uniformsNames defines the list of uniform names
  30996. * @returns an array of webGL uniform locations
  30997. */
  30998. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30999. /**
  31000. * Gets the lsit of active attributes for a given webGL program
  31001. * @param pipelineContext defines the pipeline context to use
  31002. * @param attributesNames defines the list of attribute names to get
  31003. * @returns an array of indices indicating the offset of each attribute
  31004. */
  31005. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31006. /**
  31007. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31008. * @param effect defines the effect to activate
  31009. */
  31010. enableEffect(effect: Nullable<Effect>): void;
  31011. /**
  31012. * Set the value of an uniform to an array of int32
  31013. * @param uniform defines the webGL uniform location where to store the value
  31014. * @param array defines the array of int32 to store
  31015. */
  31016. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31017. /**
  31018. * Set the value of an uniform to an array of int32 (stored as vec2)
  31019. * @param uniform defines the webGL uniform location where to store the value
  31020. * @param array defines the array of int32 to store
  31021. */
  31022. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31023. /**
  31024. * Set the value of an uniform to an array of int32 (stored as vec3)
  31025. * @param uniform defines the webGL uniform location where to store the value
  31026. * @param array defines the array of int32 to store
  31027. */
  31028. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31029. /**
  31030. * Set the value of an uniform to an array of int32 (stored as vec4)
  31031. * @param uniform defines the webGL uniform location where to store the value
  31032. * @param array defines the array of int32 to store
  31033. */
  31034. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31035. /**
  31036. * Set the value of an uniform to an array of float32
  31037. * @param uniform defines the webGL uniform location where to store the value
  31038. * @param array defines the array of float32 to store
  31039. */
  31040. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31041. /**
  31042. * Set the value of an uniform to an array of float32 (stored as vec2)
  31043. * @param uniform defines the webGL uniform location where to store the value
  31044. * @param array defines the array of float32 to store
  31045. */
  31046. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31047. /**
  31048. * Set the value of an uniform to an array of float32 (stored as vec3)
  31049. * @param uniform defines the webGL uniform location where to store the value
  31050. * @param array defines the array of float32 to store
  31051. */
  31052. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31053. /**
  31054. * Set the value of an uniform to an array of float32 (stored as vec4)
  31055. * @param uniform defines the webGL uniform location where to store the value
  31056. * @param array defines the array of float32 to store
  31057. */
  31058. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31059. /**
  31060. * Set the value of an uniform to an array of number
  31061. * @param uniform defines the webGL uniform location where to store the value
  31062. * @param array defines the array of number to store
  31063. */
  31064. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31065. /**
  31066. * Set the value of an uniform to an array of number (stored as vec2)
  31067. * @param uniform defines the webGL uniform location where to store the value
  31068. * @param array defines the array of number to store
  31069. */
  31070. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31071. /**
  31072. * Set the value of an uniform to an array of number (stored as vec3)
  31073. * @param uniform defines the webGL uniform location where to store the value
  31074. * @param array defines the array of number to store
  31075. */
  31076. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31077. /**
  31078. * Set the value of an uniform to an array of number (stored as vec4)
  31079. * @param uniform defines the webGL uniform location where to store the value
  31080. * @param array defines the array of number to store
  31081. */
  31082. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31083. /**
  31084. * Set the value of an uniform to an array of float32 (stored as matrices)
  31085. * @param uniform defines the webGL uniform location where to store the value
  31086. * @param matrices defines the array of float32 to store
  31087. */
  31088. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31089. /**
  31090. * Set the value of an uniform to a matrix (3x3)
  31091. * @param uniform defines the webGL uniform location where to store the value
  31092. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31093. */
  31094. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31095. /**
  31096. * Set the value of an uniform to a matrix (2x2)
  31097. * @param uniform defines the webGL uniform location where to store the value
  31098. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31099. */
  31100. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31101. /**
  31102. * Set the value of an uniform to a number (int)
  31103. * @param uniform defines the webGL uniform location where to store the value
  31104. * @param value defines the int number to store
  31105. */
  31106. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31107. /**
  31108. * Set the value of an uniform to a number (float)
  31109. * @param uniform defines the webGL uniform location where to store the value
  31110. * @param value defines the float number to store
  31111. */
  31112. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31113. /**
  31114. * Set the value of an uniform to a vec2
  31115. * @param uniform defines the webGL uniform location where to store the value
  31116. * @param x defines the 1st component of the value
  31117. * @param y defines the 2nd component of the value
  31118. */
  31119. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31120. /**
  31121. * Set the value of an uniform to a vec3
  31122. * @param uniform defines the webGL uniform location where to store the value
  31123. * @param x defines the 1st component of the value
  31124. * @param y defines the 2nd component of the value
  31125. * @param z defines the 3rd component of the value
  31126. */
  31127. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31128. /**
  31129. * Set the value of an uniform to a boolean
  31130. * @param uniform defines the webGL uniform location where to store the value
  31131. * @param bool defines the boolean to store
  31132. */
  31133. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31134. /**
  31135. * Set the value of an uniform to a vec4
  31136. * @param uniform defines the webGL uniform location where to store the value
  31137. * @param x defines the 1st component of the value
  31138. * @param y defines the 2nd component of the value
  31139. * @param z defines the 3rd component of the value
  31140. * @param w defines the 4th component of the value
  31141. */
  31142. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31143. /**
  31144. * Sets a Color4 on a uniform variable
  31145. * @param uniform defines the uniform location
  31146. * @param color4 defines the value to be set
  31147. */
  31148. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31149. /**
  31150. * Set various states to the webGL context
  31151. * @param culling defines backface culling state
  31152. * @param zOffset defines the value to apply to zOffset (0 by default)
  31153. * @param force defines if states must be applied even if cache is up to date
  31154. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31155. */
  31156. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31157. /**
  31158. * Set the z offset to apply to current rendering
  31159. * @param value defines the offset to apply
  31160. */
  31161. setZOffset(value: number): void;
  31162. /**
  31163. * Gets the current value of the zOffset
  31164. * @returns the current zOffset state
  31165. */
  31166. getZOffset(): number;
  31167. /**
  31168. * Enable or disable depth buffering
  31169. * @param enable defines the state to set
  31170. */
  31171. setDepthBuffer(enable: boolean): void;
  31172. /**
  31173. * Gets a boolean indicating if depth writing is enabled
  31174. * @returns the current depth writing state
  31175. */
  31176. getDepthWrite(): boolean;
  31177. /**
  31178. * Enable or disable depth writing
  31179. * @param enable defines the state to set
  31180. */
  31181. setDepthWrite(enable: boolean): void;
  31182. /**
  31183. * Enable or disable color writing
  31184. * @param enable defines the state to set
  31185. */
  31186. setColorWrite(enable: boolean): void;
  31187. /**
  31188. * Gets a boolean indicating if color writing is enabled
  31189. * @returns the current color writing state
  31190. */
  31191. getColorWrite(): boolean;
  31192. /**
  31193. * Sets alpha constants used by some alpha blending modes
  31194. * @param r defines the red component
  31195. * @param g defines the green component
  31196. * @param b defines the blue component
  31197. * @param a defines the alpha component
  31198. */
  31199. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31200. /**
  31201. * Sets the current alpha mode
  31202. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31203. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31204. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31205. */
  31206. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31207. /**
  31208. * Gets the current alpha mode
  31209. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31210. * @returns the current alpha mode
  31211. */
  31212. getAlphaMode(): number;
  31213. /**
  31214. * Clears the list of texture accessible through engine.
  31215. * This can help preventing texture load conflict due to name collision.
  31216. */
  31217. clearInternalTexturesCache(): void;
  31218. /**
  31219. * Force the entire cache to be cleared
  31220. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31221. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31222. */
  31223. wipeCaches(bruteForce?: boolean): void;
  31224. /**
  31225. * Set the compressed texture format to use, based on the formats you have, and the formats
  31226. * supported by the hardware / browser.
  31227. *
  31228. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31229. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31230. * to API arguments needed to compressed textures. This puts the burden on the container
  31231. * generator to house the arcane code for determining these for current & future formats.
  31232. *
  31233. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31234. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31235. *
  31236. * Note: The result of this call is not taken into account when a texture is base64.
  31237. *
  31238. * @param formatsAvailable defines the list of those format families you have created
  31239. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31240. *
  31241. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31242. * @returns The extension selected.
  31243. */
  31244. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31245. /** @hidden */
  31246. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31247. min: number;
  31248. mag: number;
  31249. };
  31250. /** @hidden */
  31251. _createTexture(): WebGLTexture;
  31252. /**
  31253. * Usually called from Texture.ts.
  31254. * Passed information to create a WebGLTexture
  31255. * @param urlArg defines a value which contains one of the following:
  31256. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31257. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31258. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31260. * @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)
  31261. * @param scene needed for loading to the correct scene
  31262. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31263. * @param onLoad optional callback to be called upon successful completion
  31264. * @param onError optional callback to be called upon failure
  31265. * @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
  31266. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31267. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31268. * @param forcedExtension defines the extension to use to pick the right loader
  31269. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31270. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31271. */
  31272. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31273. /**
  31274. * @hidden
  31275. * Rescales a texture
  31276. * @param source input texutre
  31277. * @param destination destination texture
  31278. * @param scene scene to use to render the resize
  31279. * @param internalFormat format to use when resizing
  31280. * @param onComplete callback to be called when resize has completed
  31281. */
  31282. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31283. private _unpackFlipYCached;
  31284. /**
  31285. * In case you are sharing the context with other applications, it might
  31286. * be interested to not cache the unpack flip y state to ensure a consistent
  31287. * value would be set.
  31288. */
  31289. enableUnpackFlipYCached: boolean;
  31290. /** @hidden */
  31291. _unpackFlipY(value: boolean): void;
  31292. /** @hidden */
  31293. _getUnpackAlignement(): number;
  31294. /**
  31295. * Creates a dynamic texture
  31296. * @param width defines the width of the texture
  31297. * @param height defines the height of the texture
  31298. * @param generateMipMaps defines if the engine should generate the mip levels
  31299. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31300. * @returns the dynamic texture inside an InternalTexture
  31301. */
  31302. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31303. /**
  31304. * Update the sampling mode of a given texture
  31305. * @param samplingMode defines the required sampling mode
  31306. * @param texture defines the texture to update
  31307. */
  31308. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31309. /**
  31310. * Update the content of a dynamic texture
  31311. * @param texture defines the texture to update
  31312. * @param canvas defines the canvas containing the source
  31313. * @param invertY defines if data must be stored with Y axis inverted
  31314. * @param premulAlpha defines if alpha is stored as premultiplied
  31315. * @param format defines the format of the data
  31316. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31317. */
  31318. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31319. /**
  31320. * Update a video texture
  31321. * @param texture defines the texture to update
  31322. * @param video defines the video element to use
  31323. * @param invertY defines if data must be stored with Y axis inverted
  31324. */
  31325. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31326. /**
  31327. * Updates a depth texture Comparison Mode and Function.
  31328. * If the comparison Function is equal to 0, the mode will be set to none.
  31329. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31330. * @param texture The texture to set the comparison function for
  31331. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31332. */
  31333. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31334. /** @hidden */
  31335. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31336. width: number;
  31337. height: number;
  31338. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31339. /**
  31340. * Creates a depth stencil texture.
  31341. * This is only available in WebGL 2 or with the depth texture extension available.
  31342. * @param size The size of face edge in the texture.
  31343. * @param options The options defining the texture.
  31344. * @returns The texture
  31345. */
  31346. createDepthStencilTexture(size: number | {
  31347. width: number;
  31348. height: number;
  31349. }, options: DepthTextureCreationOptions): InternalTexture;
  31350. /**
  31351. * Creates a depth stencil texture.
  31352. * This is only available in WebGL 2 or with the depth texture extension available.
  31353. * @param size The size of face edge in the texture.
  31354. * @param options The options defining the texture.
  31355. * @returns The texture
  31356. */
  31357. private _createDepthStencilTexture;
  31358. /**
  31359. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31360. * @param renderTarget The render target to set the frame buffer for
  31361. */
  31362. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31363. /**
  31364. * Creates a new render target texture
  31365. * @param size defines the size of the texture
  31366. * @param options defines the options used to create the texture
  31367. * @returns a new render target texture stored in an InternalTexture
  31368. */
  31369. createRenderTargetTexture(size: number | {
  31370. width: number;
  31371. height: number;
  31372. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31373. /** @hidden */
  31374. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31375. /**
  31376. * Updates the sample count of a render target texture
  31377. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31378. * @param texture defines the texture to update
  31379. * @param samples defines the sample count to set
  31380. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31381. */
  31382. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31383. /** @hidden */
  31384. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31385. /** @hidden */
  31386. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31387. /** @hidden */
  31388. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31389. /** @hidden */
  31390. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31391. /**
  31392. * @hidden
  31393. */
  31394. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31395. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31396. private _prepareWebGLTexture;
  31397. /** @hidden */
  31398. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31399. /** @hidden */
  31400. _releaseFramebufferObjects(texture: InternalTexture): void;
  31401. /** @hidden */
  31402. _releaseTexture(texture: InternalTexture): void;
  31403. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31404. protected _setProgram(program: WebGLProgram): void;
  31405. protected _boundUniforms: {
  31406. [key: number]: WebGLUniformLocation;
  31407. };
  31408. /**
  31409. * Binds an effect to the webGL context
  31410. * @param effect defines the effect to bind
  31411. */
  31412. bindSamplers(effect: Effect): void;
  31413. private _activateCurrentTexture;
  31414. /** @hidden */
  31415. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31416. /** @hidden */
  31417. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31418. /**
  31419. * Sets a texture to the webGL context from a postprocess
  31420. * @param channel defines the channel to use
  31421. * @param postProcess defines the source postprocess
  31422. */
  31423. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31424. /**
  31425. * Binds the output of the passed in post process to the texture channel specified
  31426. * @param channel The channel the texture should be bound to
  31427. * @param postProcess The post process which's output should be bound
  31428. */
  31429. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31430. /**
  31431. * Unbind all textures from the webGL context
  31432. */
  31433. unbindAllTextures(): void;
  31434. /**
  31435. * Sets a texture to the according uniform.
  31436. * @param channel The texture channel
  31437. * @param uniform The uniform to set
  31438. * @param texture The texture to apply
  31439. */
  31440. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31441. /**
  31442. * Sets a depth stencil texture from a render target to the according uniform.
  31443. * @param channel The texture channel
  31444. * @param uniform The uniform to set
  31445. * @param texture The render target texture containing the depth stencil texture to apply
  31446. */
  31447. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31448. private _bindSamplerUniformToChannel;
  31449. private _getTextureWrapMode;
  31450. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31451. /**
  31452. * Sets an array of texture to the webGL context
  31453. * @param channel defines the channel where the texture array must be set
  31454. * @param uniform defines the associated uniform location
  31455. * @param textures defines the array of textures to bind
  31456. */
  31457. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31458. /** @hidden */
  31459. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31460. private _setTextureParameterFloat;
  31461. private _setTextureParameterInteger;
  31462. /**
  31463. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31464. * @param x defines the x coordinate of the rectangle where pixels must be read
  31465. * @param y defines the y coordinate of the rectangle where pixels must be read
  31466. * @param width defines the width of the rectangle where pixels must be read
  31467. * @param height defines the height of the rectangle where pixels must be read
  31468. * @returns a Uint8Array containing RGBA colors
  31469. */
  31470. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31471. /**
  31472. * Add an externaly attached data from its key.
  31473. * This method call will fail and return false, if such key already exists.
  31474. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31475. * @param key the unique key that identifies the data
  31476. * @param data the data object to associate to the key for this Engine instance
  31477. * @return true if no such key were already present and the data was added successfully, false otherwise
  31478. */
  31479. addExternalData<T>(key: string, data: T): boolean;
  31480. /**
  31481. * Get an externaly attached data from its key
  31482. * @param key the unique key that identifies the data
  31483. * @return the associated data, if present (can be null), or undefined if not present
  31484. */
  31485. getExternalData<T>(key: string): T;
  31486. /**
  31487. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31488. * @param key the unique key that identifies the data
  31489. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31490. * @return the associated data, can be null if the factory returned null.
  31491. */
  31492. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31493. /**
  31494. * Remove an externaly attached data from the Engine instance
  31495. * @param key the unique key that identifies the data
  31496. * @return true if the data was successfully removed, false if it doesn't exist
  31497. */
  31498. removeExternalData(key: string): boolean;
  31499. /**
  31500. * Unbind all vertex attributes from the webGL context
  31501. */
  31502. unbindAllAttributes(): void;
  31503. /**
  31504. * 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
  31505. */
  31506. releaseEffects(): void;
  31507. /**
  31508. * Dispose and release all associated resources
  31509. */
  31510. dispose(): void;
  31511. /**
  31512. * Display the loading screen
  31513. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31514. */
  31515. displayLoadingUI(): void;
  31516. /**
  31517. * Hide the loading screen
  31518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31519. */
  31520. hideLoadingUI(): void;
  31521. /**
  31522. * Gets the current loading screen object
  31523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31524. */
  31525. /**
  31526. * Sets the current loading screen object
  31527. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31528. */
  31529. loadingScreen: ILoadingScreen;
  31530. /**
  31531. * Sets the current loading screen text
  31532. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31533. */
  31534. loadingUIText: string;
  31535. /**
  31536. * Sets the current loading screen background color
  31537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31538. */
  31539. loadingUIBackgroundColor: string;
  31540. /**
  31541. * Attach a new callback raised when context lost event is fired
  31542. * @param callback defines the callback to call
  31543. */
  31544. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31545. /**
  31546. * Attach a new callback raised when context restored event is fired
  31547. * @param callback defines the callback to call
  31548. */
  31549. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31550. /**
  31551. * Gets the source code of the vertex shader associated with a specific webGL program
  31552. * @param program defines the program to use
  31553. * @returns a string containing the source code of the vertex shader associated with the program
  31554. */
  31555. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31556. /**
  31557. * Gets the source code of the fragment shader associated with a specific webGL program
  31558. * @param program defines the program to use
  31559. * @returns a string containing the source code of the fragment shader associated with the program
  31560. */
  31561. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31562. /**
  31563. * Get the current error code of the webGL context
  31564. * @returns the error code
  31565. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31566. */
  31567. getError(): number;
  31568. /**
  31569. * Gets the current framerate
  31570. * @returns a number representing the framerate
  31571. */
  31572. getFps(): number;
  31573. /**
  31574. * Gets the time spent between current and previous frame
  31575. * @returns a number representing the delta time in ms
  31576. */
  31577. getDeltaTime(): number;
  31578. private _measureFps;
  31579. /** @hidden */
  31580. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31581. private _canRenderToFloatFramebuffer;
  31582. private _canRenderToHalfFloatFramebuffer;
  31583. private _canRenderToFramebuffer;
  31584. /** @hidden */
  31585. _getWebGLTextureType(type: number): number;
  31586. /** @hidden */
  31587. _getInternalFormat(format: number): number;
  31588. /** @hidden */
  31589. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31590. /** @hidden */
  31591. _getRGBAMultiSampleBufferFormat(type: number): number;
  31592. /** @hidden */
  31593. _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;
  31594. /** @hidden */
  31595. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31596. /**
  31597. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31598. * @returns true if the engine can be created
  31599. * @ignorenaming
  31600. */
  31601. static isSupported(): boolean;
  31602. /**
  31603. * Find the next highest power of two.
  31604. * @param x Number to start search from.
  31605. * @return Next highest power of two.
  31606. */
  31607. static CeilingPOT(x: number): number;
  31608. /**
  31609. * Find the next lowest power of two.
  31610. * @param x Number to start search from.
  31611. * @return Next lowest power of two.
  31612. */
  31613. static FloorPOT(x: number): number;
  31614. /**
  31615. * Find the nearest power of two.
  31616. * @param x Number to start search from.
  31617. * @return Next nearest power of two.
  31618. */
  31619. static NearestPOT(x: number): number;
  31620. /**
  31621. * Get the closest exponent of two
  31622. * @param value defines the value to approximate
  31623. * @param max defines the maximum value to return
  31624. * @param mode defines how to define the closest value
  31625. * @returns closest exponent of two of the given value
  31626. */
  31627. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31628. /**
  31629. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31630. * @param func - the function to be called
  31631. * @param requester - the object that will request the next frame. Falls back to window.
  31632. * @returns frame number
  31633. */
  31634. static QueueNewFrame(func: () => void, requester?: any): number;
  31635. /**
  31636. * Ask the browser to promote the current element to pointerlock mode
  31637. * @param element defines the DOM element to promote
  31638. */
  31639. static _RequestPointerlock(element: HTMLElement): void;
  31640. /**
  31641. * Asks the browser to exit pointerlock mode
  31642. */
  31643. static _ExitPointerlock(): void;
  31644. /**
  31645. * Ask the browser to promote the current element to fullscreen rendering mode
  31646. * @param element defines the DOM element to promote
  31647. */
  31648. static _RequestFullscreen(element: HTMLElement): void;
  31649. /**
  31650. * Asks the browser to exit fullscreen mode
  31651. */
  31652. static _ExitFullscreen(): void;
  31653. }
  31654. }
  31655. declare module BABYLON {
  31656. /**
  31657. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31658. * during the life time of the application.
  31659. */
  31660. export class EngineStore {
  31661. /** Gets the list of created engines */
  31662. static Instances: Engine[];
  31663. /** @hidden */
  31664. static _LastCreatedScene: Nullable<Scene>;
  31665. /**
  31666. * Gets the latest created engine
  31667. */
  31668. static readonly LastCreatedEngine: Nullable<Engine>;
  31669. /**
  31670. * Gets the latest created scene
  31671. */
  31672. static readonly LastCreatedScene: Nullable<Scene>;
  31673. /**
  31674. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31675. * @ignorenaming
  31676. */
  31677. static UseFallbackTexture: boolean;
  31678. /**
  31679. * Texture content used if a texture cannot loaded
  31680. * @ignorenaming
  31681. */
  31682. static FallbackTexture: string;
  31683. }
  31684. }
  31685. declare module BABYLON {
  31686. /**
  31687. * Helper class that provides a small promise polyfill
  31688. */
  31689. export class PromisePolyfill {
  31690. /**
  31691. * Static function used to check if the polyfill is required
  31692. * If this is the case then the function will inject the polyfill to window.Promise
  31693. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31694. */
  31695. static Apply(force?: boolean): void;
  31696. }
  31697. }
  31698. declare module BABYLON {
  31699. /**
  31700. * Interface for screenshot methods with describe argument called `size` as object with options
  31701. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31702. */
  31703. export interface IScreenshotSize {
  31704. /**
  31705. * number in pixels for canvas height
  31706. */
  31707. height?: number;
  31708. /**
  31709. * multiplier allowing render at a higher or lower resolution
  31710. * If value is defined then height and width will be ignored and taken from camera
  31711. */
  31712. precision?: number;
  31713. /**
  31714. * number in pixels for canvas width
  31715. */
  31716. width?: number;
  31717. }
  31718. }
  31719. declare module BABYLON {
  31720. interface IColor4Like {
  31721. r: float;
  31722. g: float;
  31723. b: float;
  31724. a: float;
  31725. }
  31726. /**
  31727. * Class containing a set of static utilities functions
  31728. */
  31729. export class Tools {
  31730. /**
  31731. * Gets or sets the base URL to use to load assets
  31732. */
  31733. static BaseUrl: string;
  31734. /**
  31735. * Enable/Disable Custom HTTP Request Headers globally.
  31736. * default = false
  31737. * @see CustomRequestHeaders
  31738. */
  31739. static UseCustomRequestHeaders: boolean;
  31740. /**
  31741. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31742. * i.e. when loading files, where the server/service expects an Authorization header
  31743. */
  31744. static CustomRequestHeaders: {
  31745. [key: string]: string;
  31746. };
  31747. /**
  31748. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31749. */
  31750. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31751. /**
  31752. * Default behaviour for cors in the application.
  31753. * It can be a string if the expected behavior is identical in the entire app.
  31754. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31755. */
  31756. static CorsBehavior: string | ((url: string | string[]) => string);
  31757. /**
  31758. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31759. * @ignorenaming
  31760. */
  31761. static UseFallbackTexture: boolean;
  31762. /**
  31763. * Use this object to register external classes like custom textures or material
  31764. * to allow the laoders to instantiate them
  31765. */
  31766. static RegisteredExternalClasses: {
  31767. [key: string]: Object;
  31768. };
  31769. /**
  31770. * Texture content used if a texture cannot loaded
  31771. * @ignorenaming
  31772. */
  31773. static fallbackTexture: string;
  31774. /**
  31775. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31776. * @param u defines the coordinate on X axis
  31777. * @param v defines the coordinate on Y axis
  31778. * @param width defines the width of the source data
  31779. * @param height defines the height of the source data
  31780. * @param pixels defines the source byte array
  31781. * @param color defines the output color
  31782. */
  31783. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31784. /**
  31785. * Interpolates between a and b via alpha
  31786. * @param a The lower value (returned when alpha = 0)
  31787. * @param b The upper value (returned when alpha = 1)
  31788. * @param alpha The interpolation-factor
  31789. * @return The mixed value
  31790. */
  31791. static Mix(a: number, b: number, alpha: number): number;
  31792. /**
  31793. * Tries to instantiate a new object from a given class name
  31794. * @param className defines the class name to instantiate
  31795. * @returns the new object or null if the system was not able to do the instantiation
  31796. */
  31797. static Instantiate(className: string): any;
  31798. /**
  31799. * Provides a slice function that will work even on IE
  31800. * @param data defines the array to slice
  31801. * @param start defines the start of the data (optional)
  31802. * @param end defines the end of the data (optional)
  31803. * @returns the new sliced array
  31804. */
  31805. static Slice<T>(data: T, start?: number, end?: number): T;
  31806. /**
  31807. * Polyfill for setImmediate
  31808. * @param action defines the action to execute after the current execution block
  31809. */
  31810. static SetImmediate(action: () => void): void;
  31811. /**
  31812. * Function indicating if a number is an exponent of 2
  31813. * @param value defines the value to test
  31814. * @returns true if the value is an exponent of 2
  31815. */
  31816. static IsExponentOfTwo(value: number): boolean;
  31817. private static _tmpFloatArray;
  31818. /**
  31819. * Returns the nearest 32-bit single precision float representation of a Number
  31820. * @param value A Number. If the parameter is of a different type, it will get converted
  31821. * to a number or to NaN if it cannot be converted
  31822. * @returns number
  31823. */
  31824. static FloatRound(value: number): number;
  31825. /**
  31826. * Extracts the filename from a path
  31827. * @param path defines the path to use
  31828. * @returns the filename
  31829. */
  31830. static GetFilename(path: string): string;
  31831. /**
  31832. * Extracts the "folder" part of a path (everything before the filename).
  31833. * @param uri The URI to extract the info from
  31834. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31835. * @returns The "folder" part of the path
  31836. */
  31837. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31838. /**
  31839. * Extracts text content from a DOM element hierarchy
  31840. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31841. */
  31842. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31843. /**
  31844. * Convert an angle in radians to degrees
  31845. * @param angle defines the angle to convert
  31846. * @returns the angle in degrees
  31847. */
  31848. static ToDegrees(angle: number): number;
  31849. /**
  31850. * Convert an angle in degrees to radians
  31851. * @param angle defines the angle to convert
  31852. * @returns the angle in radians
  31853. */
  31854. static ToRadians(angle: number): number;
  31855. /**
  31856. * Encode a buffer to a base64 string
  31857. * @param buffer defines the buffer to encode
  31858. * @returns the encoded string
  31859. */
  31860. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31861. /**
  31862. * Returns an array if obj is not an array
  31863. * @param obj defines the object to evaluate as an array
  31864. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31865. * @returns either obj directly if obj is an array or a new array containing obj
  31866. */
  31867. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31868. /**
  31869. * Gets the pointer prefix to use
  31870. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31871. */
  31872. static GetPointerPrefix(): string;
  31873. /**
  31874. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31875. * @param url define the url we are trying
  31876. * @param element define the dom element where to configure the cors policy
  31877. */
  31878. static SetCorsBehavior(url: string | string[], element: {
  31879. crossOrigin: string | null;
  31880. }): void;
  31881. /**
  31882. * Removes unwanted characters from an url
  31883. * @param url defines the url to clean
  31884. * @returns the cleaned url
  31885. */
  31886. static CleanUrl(url: string): string;
  31887. /**
  31888. * Gets or sets a function used to pre-process url before using them to load assets
  31889. */
  31890. static PreprocessUrl: (url: string) => string;
  31891. /**
  31892. * Loads an image as an HTMLImageElement.
  31893. * @param input url string, ArrayBuffer, or Blob to load
  31894. * @param onLoad callback called when the image successfully loads
  31895. * @param onError callback called when the image fails to load
  31896. * @param offlineProvider offline provider for caching
  31897. * @returns the HTMLImageElement of the loaded image
  31898. */
  31899. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31900. /**
  31901. * Loads a file
  31902. * @param url url string, ArrayBuffer, or Blob to load
  31903. * @param onSuccess callback called when the file successfully loads
  31904. * @param onProgress callback called while file is loading (if the server supports this mode)
  31905. * @param offlineProvider defines the offline provider for caching
  31906. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31907. * @param onError callback called when the file fails to load
  31908. * @returns a file request object
  31909. */
  31910. 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;
  31911. /**
  31912. * Loads a file from a url
  31913. * @param url the file url to load
  31914. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31915. */
  31916. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31917. /**
  31918. * Load a script (identified by an url). When the url returns, the
  31919. * content of this file is added into a new script element, attached to the DOM (body element)
  31920. * @param scriptUrl defines the url of the script to laod
  31921. * @param onSuccess defines the callback called when the script is loaded
  31922. * @param onError defines the callback to call if an error occurs
  31923. * @param scriptId defines the id of the script element
  31924. */
  31925. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31926. /**
  31927. * Load an asynchronous script (identified by an url). When the url returns, the
  31928. * content of this file is added into a new script element, attached to the DOM (body element)
  31929. * @param scriptUrl defines the url of the script to laod
  31930. * @param scriptId defines the id of the script element
  31931. * @returns a promise request object
  31932. */
  31933. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31934. /**
  31935. * Loads a file from a blob
  31936. * @param fileToLoad defines the blob to use
  31937. * @param callback defines the callback to call when data is loaded
  31938. * @param progressCallback defines the callback to call during loading process
  31939. * @returns a file request object
  31940. */
  31941. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31942. /**
  31943. * Loads a file
  31944. * @param fileToLoad defines the file to load
  31945. * @param callback defines the callback to call when data is loaded
  31946. * @param progressCallBack defines the callback to call during loading process
  31947. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31948. * @returns a file request object
  31949. */
  31950. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31951. /**
  31952. * Creates a data url from a given string content
  31953. * @param content defines the content to convert
  31954. * @returns the new data url link
  31955. */
  31956. static FileAsURL(content: string): string;
  31957. /**
  31958. * Format the given number to a specific decimal format
  31959. * @param value defines the number to format
  31960. * @param decimals defines the number of decimals to use
  31961. * @returns the formatted string
  31962. */
  31963. static Format(value: number, decimals?: number): string;
  31964. /**
  31965. * Tries to copy an object by duplicating every property
  31966. * @param source defines the source object
  31967. * @param destination defines the target object
  31968. * @param doNotCopyList defines a list of properties to avoid
  31969. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31970. */
  31971. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31972. /**
  31973. * Gets a boolean indicating if the given object has no own property
  31974. * @param obj defines the object to test
  31975. * @returns true if object has no own property
  31976. */
  31977. static IsEmpty(obj: any): boolean;
  31978. /**
  31979. * Function used to register events at window level
  31980. * @param windowElement defines the Window object to use
  31981. * @param events defines the events to register
  31982. */
  31983. static RegisterTopRootEvents(windowElement: Window, events: {
  31984. name: string;
  31985. handler: Nullable<(e: FocusEvent) => any>;
  31986. }[]): void;
  31987. /**
  31988. * Function used to unregister events from window level
  31989. * @param windowElement defines the Window object to use
  31990. * @param events defines the events to unregister
  31991. */
  31992. static UnregisterTopRootEvents(windowElement: Window, events: {
  31993. name: string;
  31994. handler: Nullable<(e: FocusEvent) => any>;
  31995. }[]): void;
  31996. /**
  31997. * @ignore
  31998. */
  31999. static _ScreenshotCanvas: HTMLCanvasElement;
  32000. /**
  32001. * Dumps the current bound framebuffer
  32002. * @param width defines the rendering width
  32003. * @param height defines the rendering height
  32004. * @param engine defines the hosting engine
  32005. * @param successCallback defines the callback triggered once the data are available
  32006. * @param mimeType defines the mime type of the result
  32007. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32008. */
  32009. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32010. /**
  32011. * Converts the canvas data to blob.
  32012. * This acts as a polyfill for browsers not supporting the to blob function.
  32013. * @param canvas Defines the canvas to extract the data from
  32014. * @param successCallback Defines the callback triggered once the data are available
  32015. * @param mimeType Defines the mime type of the result
  32016. */
  32017. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32018. /**
  32019. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32020. * @param successCallback defines the callback triggered once the data are available
  32021. * @param mimeType defines the mime type of the result
  32022. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32023. */
  32024. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32025. /**
  32026. * Downloads a blob in the browser
  32027. * @param blob defines the blob to download
  32028. * @param fileName defines the name of the downloaded file
  32029. */
  32030. static Download(blob: Blob, fileName: string): void;
  32031. /**
  32032. * Captures a screenshot of the current rendering
  32033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32034. * @param engine defines the rendering engine
  32035. * @param camera defines the source camera
  32036. * @param size This parameter can be set to a single number or to an object with the
  32037. * following (optional) properties: precision, width, height. If a single number is passed,
  32038. * it will be used for both width and height. If an object is passed, the screenshot size
  32039. * will be derived from the parameters. The precision property is a multiplier allowing
  32040. * rendering at a higher or lower resolution
  32041. * @param successCallback defines the callback receives a single parameter which contains the
  32042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32043. * src parameter of an <img> to display it
  32044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32045. * Check your browser for supported MIME types
  32046. */
  32047. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32048. /**
  32049. * Captures a screenshot of the current rendering
  32050. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32051. * @param engine defines the rendering engine
  32052. * @param camera defines the source camera
  32053. * @param size This parameter can be set to a single number or to an object with the
  32054. * following (optional) properties: precision, width, height. If a single number is passed,
  32055. * it will be used for both width and height. If an object is passed, the screenshot size
  32056. * will be derived from the parameters. The precision property is a multiplier allowing
  32057. * rendering at a higher or lower resolution
  32058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32059. * Check your browser for supported MIME types
  32060. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32061. * to the src parameter of an <img> to display it
  32062. */
  32063. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32064. /**
  32065. * Generates an image screenshot from the specified camera.
  32066. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32067. * @param engine The engine to use for rendering
  32068. * @param camera The camera to use for rendering
  32069. * @param size This parameter can be set to a single number or to an object with the
  32070. * following (optional) properties: precision, width, height. If a single number is passed,
  32071. * it will be used for both width and height. If an object is passed, the screenshot size
  32072. * will be derived from the parameters. The precision property is a multiplier allowing
  32073. * rendering at a higher or lower resolution
  32074. * @param successCallback The callback receives a single parameter which contains the
  32075. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32076. * src parameter of an <img> to display it
  32077. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32078. * Check your browser for supported MIME types
  32079. * @param samples Texture samples (default: 1)
  32080. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32081. * @param fileName A name for for the downloaded file.
  32082. */
  32083. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32084. /**
  32085. * Generates an image screenshot from the specified camera.
  32086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32087. * @param engine The engine to use for rendering
  32088. * @param camera The camera to use for rendering
  32089. * @param size This parameter can be set to a single number or to an object with the
  32090. * following (optional) properties: precision, width, height. If a single number is passed,
  32091. * it will be used for both width and height. If an object is passed, the screenshot size
  32092. * will be derived from the parameters. The precision property is a multiplier allowing
  32093. * rendering at a higher or lower resolution
  32094. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32095. * Check your browser for supported MIME types
  32096. * @param samples Texture samples (default: 1)
  32097. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32098. * @param fileName A name for for the downloaded file.
  32099. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32100. * to the src parameter of an <img> to display it
  32101. */
  32102. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32103. /**
  32104. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32105. * Be aware Math.random() could cause collisions, but:
  32106. * "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"
  32107. * @returns a pseudo random id
  32108. */
  32109. static RandomId(): string;
  32110. /**
  32111. * Test if the given uri is a base64 string
  32112. * @param uri The uri to test
  32113. * @return True if the uri is a base64 string or false otherwise
  32114. */
  32115. static IsBase64(uri: string): boolean;
  32116. /**
  32117. * Decode the given base64 uri.
  32118. * @param uri The uri to decode
  32119. * @return The decoded base64 data.
  32120. */
  32121. static DecodeBase64(uri: string): ArrayBuffer;
  32122. /**
  32123. * Gets the absolute url.
  32124. * @param url the input url
  32125. * @return the absolute url
  32126. */
  32127. static GetAbsoluteUrl(url: string): string;
  32128. /**
  32129. * No log
  32130. */
  32131. static readonly NoneLogLevel: number;
  32132. /**
  32133. * Only message logs
  32134. */
  32135. static readonly MessageLogLevel: number;
  32136. /**
  32137. * Only warning logs
  32138. */
  32139. static readonly WarningLogLevel: number;
  32140. /**
  32141. * Only error logs
  32142. */
  32143. static readonly ErrorLogLevel: number;
  32144. /**
  32145. * All logs
  32146. */
  32147. static readonly AllLogLevel: number;
  32148. /**
  32149. * Gets a value indicating the number of loading errors
  32150. * @ignorenaming
  32151. */
  32152. static readonly errorsCount: number;
  32153. /**
  32154. * Callback called when a new log is added
  32155. */
  32156. static OnNewCacheEntry: (entry: string) => void;
  32157. /**
  32158. * Log a message to the console
  32159. * @param message defines the message to log
  32160. */
  32161. static Log(message: string): void;
  32162. /**
  32163. * Write a warning message to the console
  32164. * @param message defines the message to log
  32165. */
  32166. static Warn(message: string): void;
  32167. /**
  32168. * Write an error message to the console
  32169. * @param message defines the message to log
  32170. */
  32171. static Error(message: string): void;
  32172. /**
  32173. * Gets current log cache (list of logs)
  32174. */
  32175. static readonly LogCache: string;
  32176. /**
  32177. * Clears the log cache
  32178. */
  32179. static ClearLogCache(): void;
  32180. /**
  32181. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32182. */
  32183. static LogLevels: number;
  32184. /**
  32185. * Checks if the window object exists
  32186. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32187. */
  32188. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32189. /**
  32190. * No performance log
  32191. */
  32192. static readonly PerformanceNoneLogLevel: number;
  32193. /**
  32194. * Use user marks to log performance
  32195. */
  32196. static readonly PerformanceUserMarkLogLevel: number;
  32197. /**
  32198. * Log performance to the console
  32199. */
  32200. static readonly PerformanceConsoleLogLevel: number;
  32201. private static _performance;
  32202. /**
  32203. * Sets the current performance log level
  32204. */
  32205. static PerformanceLogLevel: number;
  32206. private static _StartPerformanceCounterDisabled;
  32207. private static _EndPerformanceCounterDisabled;
  32208. private static _StartUserMark;
  32209. private static _EndUserMark;
  32210. private static _StartPerformanceConsole;
  32211. private static _EndPerformanceConsole;
  32212. /**
  32213. * Starts a performance counter
  32214. */
  32215. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32216. /**
  32217. * Ends a specific performance coutner
  32218. */
  32219. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32220. /**
  32221. * Gets either window.performance.now() if supported or Date.now() else
  32222. */
  32223. static readonly Now: number;
  32224. /**
  32225. * This method will return the name of the class used to create the instance of the given object.
  32226. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32227. * @param object the object to get the class name from
  32228. * @param isType defines if the object is actually a type
  32229. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32230. */
  32231. static GetClassName(object: any, isType?: boolean): string;
  32232. /**
  32233. * Gets the first element of an array satisfying a given predicate
  32234. * @param array defines the array to browse
  32235. * @param predicate defines the predicate to use
  32236. * @returns null if not found or the element
  32237. */
  32238. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32239. /**
  32240. * This method will return the name of the full name of the class, including its owning module (if any).
  32241. * 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).
  32242. * @param object the object to get the class name from
  32243. * @param isType defines if the object is actually a type
  32244. * @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.
  32245. * @ignorenaming
  32246. */
  32247. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32248. /**
  32249. * Returns a promise that resolves after the given amount of time.
  32250. * @param delay Number of milliseconds to delay
  32251. * @returns Promise that resolves after the given amount of time
  32252. */
  32253. static DelayAsync(delay: number): Promise<void>;
  32254. }
  32255. /**
  32256. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32257. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32258. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32259. * @param name The name of the class, case should be preserved
  32260. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32261. */
  32262. export function className(name: string, module?: string): (target: Object) => void;
  32263. /**
  32264. * An implementation of a loop for asynchronous functions.
  32265. */
  32266. export class AsyncLoop {
  32267. /**
  32268. * Defines the number of iterations for the loop
  32269. */
  32270. iterations: number;
  32271. /**
  32272. * Defines the current index of the loop.
  32273. */
  32274. index: number;
  32275. private _done;
  32276. private _fn;
  32277. private _successCallback;
  32278. /**
  32279. * Constructor.
  32280. * @param iterations the number of iterations.
  32281. * @param func the function to run each iteration
  32282. * @param successCallback the callback that will be called upon succesful execution
  32283. * @param offset starting offset.
  32284. */
  32285. constructor(
  32286. /**
  32287. * Defines the number of iterations for the loop
  32288. */
  32289. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32290. /**
  32291. * Execute the next iteration. Must be called after the last iteration was finished.
  32292. */
  32293. executeNext(): void;
  32294. /**
  32295. * Break the loop and run the success callback.
  32296. */
  32297. breakLoop(): void;
  32298. /**
  32299. * Create and run an async loop.
  32300. * @param iterations the number of iterations.
  32301. * @param fn the function to run each iteration
  32302. * @param successCallback the callback that will be called upon succesful execution
  32303. * @param offset starting offset.
  32304. * @returns the created async loop object
  32305. */
  32306. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32307. /**
  32308. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32309. * @param iterations total number of iterations
  32310. * @param syncedIterations number of synchronous iterations in each async iteration.
  32311. * @param fn the function to call each iteration.
  32312. * @param callback a success call back that will be called when iterating stops.
  32313. * @param breakFunction a break condition (optional)
  32314. * @param timeout timeout settings for the setTimeout function. default - 0.
  32315. * @returns the created async loop object
  32316. */
  32317. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32318. }
  32319. }
  32320. declare module BABYLON {
  32321. /** @hidden */
  32322. export interface ICollisionCoordinator {
  32323. createCollider(): Collider;
  32324. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32325. init(scene: Scene): void;
  32326. }
  32327. /** @hidden */
  32328. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32329. private _scene;
  32330. private _scaledPosition;
  32331. private _scaledVelocity;
  32332. private _finalPosition;
  32333. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32334. createCollider(): Collider;
  32335. init(scene: Scene): void;
  32336. private _collideWithWorld;
  32337. }
  32338. }
  32339. declare module BABYLON {
  32340. /**
  32341. * Class used to manage all inputs for the scene.
  32342. */
  32343. export class InputManager {
  32344. /** The distance in pixel that you have to move to prevent some events */
  32345. static DragMovementThreshold: number;
  32346. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32347. static LongPressDelay: number;
  32348. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32349. static DoubleClickDelay: number;
  32350. /** If you need to check double click without raising a single click at first click, enable this flag */
  32351. static ExclusiveDoubleClickMode: boolean;
  32352. private _wheelEventName;
  32353. private _onPointerMove;
  32354. private _onPointerDown;
  32355. private _onPointerUp;
  32356. private _initClickEvent;
  32357. private _initActionManager;
  32358. private _delayedSimpleClick;
  32359. private _delayedSimpleClickTimeout;
  32360. private _previousDelayedSimpleClickTimeout;
  32361. private _meshPickProceed;
  32362. private _previousButtonPressed;
  32363. private _currentPickResult;
  32364. private _previousPickResult;
  32365. private _totalPointersPressed;
  32366. private _doubleClickOccured;
  32367. private _pointerOverMesh;
  32368. private _pickedDownMesh;
  32369. private _pickedUpMesh;
  32370. private _pointerX;
  32371. private _pointerY;
  32372. private _unTranslatedPointerX;
  32373. private _unTranslatedPointerY;
  32374. private _startingPointerPosition;
  32375. private _previousStartingPointerPosition;
  32376. private _startingPointerTime;
  32377. private _previousStartingPointerTime;
  32378. private _pointerCaptures;
  32379. private _onKeyDown;
  32380. private _onKeyUp;
  32381. private _onCanvasFocusObserver;
  32382. private _onCanvasBlurObserver;
  32383. private _scene;
  32384. /**
  32385. * Creates a new InputManager
  32386. * @param scene defines the hosting scene
  32387. */
  32388. constructor(scene: Scene);
  32389. /**
  32390. * Gets the mesh that is currently under the pointer
  32391. */
  32392. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32393. /**
  32394. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32395. */
  32396. readonly unTranslatedPointer: Vector2;
  32397. /**
  32398. * Gets or sets the current on-screen X position of the pointer
  32399. */
  32400. pointerX: number;
  32401. /**
  32402. * Gets or sets the current on-screen Y position of the pointer
  32403. */
  32404. pointerY: number;
  32405. private _updatePointerPosition;
  32406. private _processPointerMove;
  32407. private _setRayOnPointerInfo;
  32408. private _checkPrePointerObservable;
  32409. /**
  32410. * Use this method to simulate a pointer move on a mesh
  32411. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32412. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32413. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32414. */
  32415. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32416. /**
  32417. * Use this method to simulate a pointer down on a mesh
  32418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32421. */
  32422. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32423. private _processPointerDown;
  32424. /** @hidden */
  32425. _isPointerSwiping(): boolean;
  32426. /**
  32427. * Use this method to simulate a pointer up on a mesh
  32428. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32429. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32430. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32431. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32432. */
  32433. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32434. private _processPointerUp;
  32435. /**
  32436. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32437. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32438. * @returns true if the pointer was captured
  32439. */
  32440. isPointerCaptured(pointerId?: number): boolean;
  32441. /**
  32442. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32443. * @param attachUp defines if you want to attach events to pointerup
  32444. * @param attachDown defines if you want to attach events to pointerdown
  32445. * @param attachMove defines if you want to attach events to pointermove
  32446. */
  32447. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32448. /**
  32449. * Detaches all event handlers
  32450. */
  32451. detachControl(): void;
  32452. /**
  32453. * Force the value of meshUnderPointer
  32454. * @param mesh defines the mesh to use
  32455. */
  32456. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32457. /**
  32458. * Gets the mesh under the pointer
  32459. * @returns a Mesh or null if no mesh is under the pointer
  32460. */
  32461. getPointerOverMesh(): Nullable<AbstractMesh>;
  32462. }
  32463. }
  32464. declare module BABYLON {
  32465. /**
  32466. * Helper class used to generate session unique ID
  32467. */
  32468. export class UniqueIdGenerator {
  32469. private static _UniqueIdCounter;
  32470. /**
  32471. * Gets an unique (relatively to the current scene) Id
  32472. */
  32473. static readonly UniqueId: number;
  32474. }
  32475. }
  32476. declare module BABYLON {
  32477. /**
  32478. * This class defines the direct association between an animation and a target
  32479. */
  32480. export class TargetedAnimation {
  32481. /**
  32482. * Animation to perform
  32483. */
  32484. animation: Animation;
  32485. /**
  32486. * Target to animate
  32487. */
  32488. target: any;
  32489. /**
  32490. * Serialize the object
  32491. * @returns the JSON object representing the current entity
  32492. */
  32493. serialize(): any;
  32494. }
  32495. /**
  32496. * Use this class to create coordinated animations on multiple targets
  32497. */
  32498. export class AnimationGroup implements IDisposable {
  32499. /** The name of the animation group */
  32500. name: string;
  32501. private _scene;
  32502. private _targetedAnimations;
  32503. private _animatables;
  32504. private _from;
  32505. private _to;
  32506. private _isStarted;
  32507. private _isPaused;
  32508. private _speedRatio;
  32509. private _loopAnimation;
  32510. /**
  32511. * Gets or sets the unique id of the node
  32512. */
  32513. uniqueId: number;
  32514. /**
  32515. * This observable will notify when one animation have ended
  32516. */
  32517. onAnimationEndObservable: Observable<TargetedAnimation>;
  32518. /**
  32519. * Observer raised when one animation loops
  32520. */
  32521. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32522. /**
  32523. * This observable will notify when all animations have ended.
  32524. */
  32525. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32526. /**
  32527. * This observable will notify when all animations have paused.
  32528. */
  32529. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32530. /**
  32531. * This observable will notify when all animations are playing.
  32532. */
  32533. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32534. /**
  32535. * Gets the first frame
  32536. */
  32537. readonly from: number;
  32538. /**
  32539. * Gets the last frame
  32540. */
  32541. readonly to: number;
  32542. /**
  32543. * Define if the animations are started
  32544. */
  32545. readonly isStarted: boolean;
  32546. /**
  32547. * Gets a value indicating that the current group is playing
  32548. */
  32549. readonly isPlaying: boolean;
  32550. /**
  32551. * Gets or sets the speed ratio to use for all animations
  32552. */
  32553. /**
  32554. * Gets or sets the speed ratio to use for all animations
  32555. */
  32556. speedRatio: number;
  32557. /**
  32558. * Gets or sets if all animations should loop or not
  32559. */
  32560. loopAnimation: boolean;
  32561. /**
  32562. * Gets the targeted animations for this animation group
  32563. */
  32564. readonly targetedAnimations: Array<TargetedAnimation>;
  32565. /**
  32566. * returning the list of animatables controlled by this animation group.
  32567. */
  32568. readonly animatables: Array<Animatable>;
  32569. /**
  32570. * Instantiates a new Animation Group.
  32571. * This helps managing several animations at once.
  32572. * @see http://doc.babylonjs.com/how_to/group
  32573. * @param name Defines the name of the group
  32574. * @param scene Defines the scene the group belongs to
  32575. */
  32576. constructor(
  32577. /** The name of the animation group */
  32578. name: string, scene?: Nullable<Scene>);
  32579. /**
  32580. * Add an animation (with its target) in the group
  32581. * @param animation defines the animation we want to add
  32582. * @param target defines the target of the animation
  32583. * @returns the TargetedAnimation object
  32584. */
  32585. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32586. /**
  32587. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32588. * It can add constant keys at begin or end
  32589. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32590. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32591. * @returns the animation group
  32592. */
  32593. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32594. /**
  32595. * Start all animations on given targets
  32596. * @param loop defines if animations must loop
  32597. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32598. * @param from defines the from key (optional)
  32599. * @param to defines the to key (optional)
  32600. * @returns the current animation group
  32601. */
  32602. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32603. /**
  32604. * Pause all animations
  32605. * @returns the animation group
  32606. */
  32607. pause(): AnimationGroup;
  32608. /**
  32609. * Play all animations to initial state
  32610. * This function will start() the animations if they were not started or will restart() them if they were paused
  32611. * @param loop defines if animations must loop
  32612. * @returns the animation group
  32613. */
  32614. play(loop?: boolean): AnimationGroup;
  32615. /**
  32616. * Reset all animations to initial state
  32617. * @returns the animation group
  32618. */
  32619. reset(): AnimationGroup;
  32620. /**
  32621. * Restart animations from key 0
  32622. * @returns the animation group
  32623. */
  32624. restart(): AnimationGroup;
  32625. /**
  32626. * Stop all animations
  32627. * @returns the animation group
  32628. */
  32629. stop(): AnimationGroup;
  32630. /**
  32631. * Set animation weight for all animatables
  32632. * @param weight defines the weight to use
  32633. * @return the animationGroup
  32634. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32635. */
  32636. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32637. /**
  32638. * Synchronize and normalize all animatables with a source animatable
  32639. * @param root defines the root animatable to synchronize with
  32640. * @return the animationGroup
  32641. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32642. */
  32643. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32644. /**
  32645. * Goes to a specific frame in this animation group
  32646. * @param frame the frame number to go to
  32647. * @return the animationGroup
  32648. */
  32649. goToFrame(frame: number): AnimationGroup;
  32650. /**
  32651. * Dispose all associated resources
  32652. */
  32653. dispose(): void;
  32654. private _checkAnimationGroupEnded;
  32655. /**
  32656. * Clone the current animation group and returns a copy
  32657. * @param newName defines the name of the new group
  32658. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32659. * @returns the new aniamtion group
  32660. */
  32661. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32662. /**
  32663. * Serializes the animationGroup to an object
  32664. * @returns Serialized object
  32665. */
  32666. serialize(): any;
  32667. /**
  32668. * Returns a new AnimationGroup object parsed from the source provided.
  32669. * @param parsedAnimationGroup defines the source
  32670. * @param scene defines the scene that will receive the animationGroup
  32671. * @returns a new AnimationGroup
  32672. */
  32673. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32674. /**
  32675. * Returns the string "AnimationGroup"
  32676. * @returns "AnimationGroup"
  32677. */
  32678. getClassName(): string;
  32679. /**
  32680. * Creates a detailled string about the object
  32681. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32682. * @returns a string representing the object
  32683. */
  32684. toString(fullDetails?: boolean): string;
  32685. }
  32686. }
  32687. declare module BABYLON {
  32688. /**
  32689. * Define an interface for all classes that will hold resources
  32690. */
  32691. export interface IDisposable {
  32692. /**
  32693. * Releases all held resources
  32694. */
  32695. dispose(): void;
  32696. }
  32697. /** Interface defining initialization parameters for Scene class */
  32698. export interface SceneOptions {
  32699. /**
  32700. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32701. * It will improve performance when the number of geometries becomes important.
  32702. */
  32703. useGeometryUniqueIdsMap?: boolean;
  32704. /**
  32705. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32706. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32707. */
  32708. useMaterialMeshMap?: boolean;
  32709. /**
  32710. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32711. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32712. */
  32713. useClonedMeshhMap?: boolean;
  32714. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32715. virtual?: boolean;
  32716. }
  32717. /**
  32718. * Represents a scene to be rendered by the engine.
  32719. * @see http://doc.babylonjs.com/features/scene
  32720. */
  32721. export class Scene extends AbstractScene implements IAnimatable {
  32722. /** The fog is deactivated */
  32723. static readonly FOGMODE_NONE: number;
  32724. /** The fog density is following an exponential function */
  32725. static readonly FOGMODE_EXP: number;
  32726. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32727. static readonly FOGMODE_EXP2: number;
  32728. /** The fog density is following a linear function. */
  32729. static readonly FOGMODE_LINEAR: number;
  32730. /**
  32731. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32733. */
  32734. static MinDeltaTime: number;
  32735. /**
  32736. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32738. */
  32739. static MaxDeltaTime: number;
  32740. /**
  32741. * Factory used to create the default material.
  32742. * @param name The name of the material to create
  32743. * @param scene The scene to create the material for
  32744. * @returns The default material
  32745. */
  32746. static DefaultMaterialFactory(scene: Scene): Material;
  32747. /**
  32748. * Factory used to create the a collision coordinator.
  32749. * @returns The collision coordinator
  32750. */
  32751. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32752. /** @hidden */
  32753. _inputManager: InputManager;
  32754. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32755. cameraToUseForPointers: Nullable<Camera>;
  32756. /** @hidden */
  32757. readonly _isScene: boolean;
  32758. /**
  32759. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32760. */
  32761. autoClear: boolean;
  32762. /**
  32763. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32764. */
  32765. autoClearDepthAndStencil: boolean;
  32766. /**
  32767. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32768. */
  32769. clearColor: Color4;
  32770. /**
  32771. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32772. */
  32773. ambientColor: Color3;
  32774. /**
  32775. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32776. * It should only be one of the following (if not the default embedded one):
  32777. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32778. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32779. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32780. * The material properties need to be setup according to the type of texture in use.
  32781. */
  32782. environmentBRDFTexture: BaseTexture;
  32783. /** @hidden */
  32784. protected _environmentTexture: Nullable<BaseTexture>;
  32785. /**
  32786. * Texture used in all pbr material as the reflection texture.
  32787. * As in the majority of the scene they are the same (exception for multi room and so on),
  32788. * this is easier to reference from here than from all the materials.
  32789. */
  32790. /**
  32791. * Texture used in all pbr material as the reflection texture.
  32792. * As in the majority of the scene they are the same (exception for multi room and so on),
  32793. * this is easier to set here than in all the materials.
  32794. */
  32795. environmentTexture: Nullable<BaseTexture>;
  32796. /** @hidden */
  32797. protected _environmentIntensity: number;
  32798. /**
  32799. * Intensity of the environment in all pbr material.
  32800. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32801. * As in the majority of the scene they are the same (exception for multi room and so on),
  32802. * this is easier to reference from here than from all the materials.
  32803. */
  32804. /**
  32805. * Intensity of the environment in all pbr material.
  32806. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32807. * As in the majority of the scene they are the same (exception for multi room and so on),
  32808. * this is easier to set here than in all the materials.
  32809. */
  32810. environmentIntensity: number;
  32811. /** @hidden */
  32812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32813. /**
  32814. * Default image processing configuration used either in the rendering
  32815. * Forward main pass or through the imageProcessingPostProcess if present.
  32816. * As in the majority of the scene they are the same (exception for multi camera),
  32817. * this is easier to reference from here than from all the materials and post process.
  32818. *
  32819. * No setter as we it is a shared configuration, you can set the values instead.
  32820. */
  32821. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32822. private _forceWireframe;
  32823. /**
  32824. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32825. */
  32826. forceWireframe: boolean;
  32827. private _forcePointsCloud;
  32828. /**
  32829. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32830. */
  32831. forcePointsCloud: boolean;
  32832. /**
  32833. * Gets or sets the active clipplane 1
  32834. */
  32835. clipPlane: Nullable<Plane>;
  32836. /**
  32837. * Gets or sets the active clipplane 2
  32838. */
  32839. clipPlane2: Nullable<Plane>;
  32840. /**
  32841. * Gets or sets the active clipplane 3
  32842. */
  32843. clipPlane3: Nullable<Plane>;
  32844. /**
  32845. * Gets or sets the active clipplane 4
  32846. */
  32847. clipPlane4: Nullable<Plane>;
  32848. /**
  32849. * Gets or sets a boolean indicating if animations are enabled
  32850. */
  32851. animationsEnabled: boolean;
  32852. private _animationPropertiesOverride;
  32853. /**
  32854. * Gets or sets the animation properties override
  32855. */
  32856. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32857. /**
  32858. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32859. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32860. */
  32861. useConstantAnimationDeltaTime: boolean;
  32862. /**
  32863. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32864. * Please note that it requires to run a ray cast through the scene on every frame
  32865. */
  32866. constantlyUpdateMeshUnderPointer: boolean;
  32867. /**
  32868. * Defines the HTML cursor to use when hovering over interactive elements
  32869. */
  32870. hoverCursor: string;
  32871. /**
  32872. * Defines the HTML default cursor to use (empty by default)
  32873. */
  32874. defaultCursor: string;
  32875. /**
  32876. * This is used to call preventDefault() on pointer down
  32877. * in order to block unwanted artifacts like system double clicks
  32878. */
  32879. preventDefaultOnPointerDown: boolean;
  32880. /**
  32881. * This is used to call preventDefault() on pointer up
  32882. * in order to block unwanted artifacts like system double clicks
  32883. */
  32884. preventDefaultOnPointerUp: boolean;
  32885. /**
  32886. * Gets or sets user defined metadata
  32887. */
  32888. metadata: any;
  32889. /**
  32890. * For internal use only. Please do not use.
  32891. */
  32892. reservedDataStore: any;
  32893. /**
  32894. * Gets the name of the plugin used to load this scene (null by default)
  32895. */
  32896. loadingPluginName: string;
  32897. /**
  32898. * Use this array to add regular expressions used to disable offline support for specific urls
  32899. */
  32900. disableOfflineSupportExceptionRules: RegExp[];
  32901. /**
  32902. * An event triggered when the scene is disposed.
  32903. */
  32904. onDisposeObservable: Observable<Scene>;
  32905. private _onDisposeObserver;
  32906. /** Sets a function to be executed when this scene is disposed. */
  32907. onDispose: () => void;
  32908. /**
  32909. * An event triggered before rendering the scene (right after animations and physics)
  32910. */
  32911. onBeforeRenderObservable: Observable<Scene>;
  32912. private _onBeforeRenderObserver;
  32913. /** Sets a function to be executed before rendering this scene */
  32914. beforeRender: Nullable<() => void>;
  32915. /**
  32916. * An event triggered after rendering the scene
  32917. */
  32918. onAfterRenderObservable: Observable<Scene>;
  32919. /**
  32920. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32921. */
  32922. onAfterRenderCameraObservable: Observable<Camera>;
  32923. private _onAfterRenderObserver;
  32924. /** Sets a function to be executed after rendering this scene */
  32925. afterRender: Nullable<() => void>;
  32926. /**
  32927. * An event triggered before animating the scene
  32928. */
  32929. onBeforeAnimationsObservable: Observable<Scene>;
  32930. /**
  32931. * An event triggered after animations processing
  32932. */
  32933. onAfterAnimationsObservable: Observable<Scene>;
  32934. /**
  32935. * An event triggered before draw calls are ready to be sent
  32936. */
  32937. onBeforeDrawPhaseObservable: Observable<Scene>;
  32938. /**
  32939. * An event triggered after draw calls have been sent
  32940. */
  32941. onAfterDrawPhaseObservable: Observable<Scene>;
  32942. /**
  32943. * An event triggered when the scene is ready
  32944. */
  32945. onReadyObservable: Observable<Scene>;
  32946. /**
  32947. * An event triggered before rendering a camera
  32948. */
  32949. onBeforeCameraRenderObservable: Observable<Camera>;
  32950. private _onBeforeCameraRenderObserver;
  32951. /** Sets a function to be executed before rendering a camera*/
  32952. beforeCameraRender: () => void;
  32953. /**
  32954. * An event triggered after rendering a camera
  32955. */
  32956. onAfterCameraRenderObservable: Observable<Camera>;
  32957. private _onAfterCameraRenderObserver;
  32958. /** Sets a function to be executed after rendering a camera*/
  32959. afterCameraRender: () => void;
  32960. /**
  32961. * An event triggered when active meshes evaluation is about to start
  32962. */
  32963. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32964. /**
  32965. * An event triggered when active meshes evaluation is done
  32966. */
  32967. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32968. /**
  32969. * An event triggered when particles rendering is about to start
  32970. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32971. */
  32972. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32973. /**
  32974. * An event triggered when particles rendering is done
  32975. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32976. */
  32977. onAfterParticlesRenderingObservable: Observable<Scene>;
  32978. /**
  32979. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32980. */
  32981. onDataLoadedObservable: Observable<Scene>;
  32982. /**
  32983. * An event triggered when a camera is created
  32984. */
  32985. onNewCameraAddedObservable: Observable<Camera>;
  32986. /**
  32987. * An event triggered when a camera is removed
  32988. */
  32989. onCameraRemovedObservable: Observable<Camera>;
  32990. /**
  32991. * An event triggered when a light is created
  32992. */
  32993. onNewLightAddedObservable: Observable<Light>;
  32994. /**
  32995. * An event triggered when a light is removed
  32996. */
  32997. onLightRemovedObservable: Observable<Light>;
  32998. /**
  32999. * An event triggered when a geometry is created
  33000. */
  33001. onNewGeometryAddedObservable: Observable<Geometry>;
  33002. /**
  33003. * An event triggered when a geometry is removed
  33004. */
  33005. onGeometryRemovedObservable: Observable<Geometry>;
  33006. /**
  33007. * An event triggered when a transform node is created
  33008. */
  33009. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33010. /**
  33011. * An event triggered when a transform node is removed
  33012. */
  33013. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33014. /**
  33015. * An event triggered when a mesh is created
  33016. */
  33017. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33018. /**
  33019. * An event triggered when a mesh is removed
  33020. */
  33021. onMeshRemovedObservable: Observable<AbstractMesh>;
  33022. /**
  33023. * An event triggered when a skeleton is created
  33024. */
  33025. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33026. /**
  33027. * An event triggered when a skeleton is removed
  33028. */
  33029. onSkeletonRemovedObservable: Observable<Skeleton>;
  33030. /**
  33031. * An event triggered when a material is created
  33032. */
  33033. onNewMaterialAddedObservable: Observable<Material>;
  33034. /**
  33035. * An event triggered when a material is removed
  33036. */
  33037. onMaterialRemovedObservable: Observable<Material>;
  33038. /**
  33039. * An event triggered when a texture is created
  33040. */
  33041. onNewTextureAddedObservable: Observable<BaseTexture>;
  33042. /**
  33043. * An event triggered when a texture is removed
  33044. */
  33045. onTextureRemovedObservable: Observable<BaseTexture>;
  33046. /**
  33047. * An event triggered when render targets are about to be rendered
  33048. * Can happen multiple times per frame.
  33049. */
  33050. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33051. /**
  33052. * An event triggered when render targets were rendered.
  33053. * Can happen multiple times per frame.
  33054. */
  33055. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered before calculating deterministic simulation step
  33058. */
  33059. onBeforeStepObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered after calculating deterministic simulation step
  33062. */
  33063. onAfterStepObservable: Observable<Scene>;
  33064. /**
  33065. * An event triggered when the activeCamera property is updated
  33066. */
  33067. onActiveCameraChanged: Observable<Scene>;
  33068. /**
  33069. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33070. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33071. * 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)
  33072. */
  33073. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33074. /**
  33075. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33076. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33077. * 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)
  33078. */
  33079. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33080. /**
  33081. * This Observable will when a mesh has been imported into the scene.
  33082. */
  33083. onMeshImportedObservable: Observable<AbstractMesh>;
  33084. /**
  33085. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33086. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33087. */
  33088. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33089. /** @hidden */
  33090. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33091. /**
  33092. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33093. */
  33094. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33095. /**
  33096. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33097. */
  33098. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33099. /**
  33100. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33101. */
  33102. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33103. /** Callback called when a pointer move is detected */
  33104. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33105. /** Callback called when a pointer down is detected */
  33106. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33107. /** Callback called when a pointer up is detected */
  33108. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33109. /** Callback called when a pointer pick is detected */
  33110. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33111. /**
  33112. * 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).
  33113. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33114. */
  33115. onPrePointerObservable: Observable<PointerInfoPre>;
  33116. /**
  33117. * Observable event triggered each time an input event is received from the rendering canvas
  33118. */
  33119. onPointerObservable: Observable<PointerInfo>;
  33120. /**
  33121. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33122. */
  33123. readonly unTranslatedPointer: Vector2;
  33124. /**
  33125. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33126. */
  33127. static DragMovementThreshold: number;
  33128. /**
  33129. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33130. */
  33131. static LongPressDelay: number;
  33132. /**
  33133. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33134. */
  33135. static DoubleClickDelay: number;
  33136. /** If you need to check double click without raising a single click at first click, enable this flag */
  33137. static ExclusiveDoubleClickMode: boolean;
  33138. /** @hidden */
  33139. _mirroredCameraPosition: Nullable<Vector3>;
  33140. /**
  33141. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33142. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33143. */
  33144. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33145. /**
  33146. * Observable event triggered each time an keyboard event is received from the hosting window
  33147. */
  33148. onKeyboardObservable: Observable<KeyboardInfo>;
  33149. private _useRightHandedSystem;
  33150. /**
  33151. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33152. */
  33153. useRightHandedSystem: boolean;
  33154. private _timeAccumulator;
  33155. private _currentStepId;
  33156. private _currentInternalStep;
  33157. /**
  33158. * Sets the step Id used by deterministic lock step
  33159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33160. * @param newStepId defines the step Id
  33161. */
  33162. setStepId(newStepId: number): void;
  33163. /**
  33164. * Gets the step Id used by deterministic lock step
  33165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33166. * @returns the step Id
  33167. */
  33168. getStepId(): number;
  33169. /**
  33170. * Gets the internal step used by deterministic lock step
  33171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33172. * @returns the internal step
  33173. */
  33174. getInternalStep(): number;
  33175. private _fogEnabled;
  33176. /**
  33177. * Gets or sets a boolean indicating if fog is enabled on this scene
  33178. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33179. * (Default is true)
  33180. */
  33181. fogEnabled: boolean;
  33182. private _fogMode;
  33183. /**
  33184. * Gets or sets the fog mode to use
  33185. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33186. * | mode | value |
  33187. * | --- | --- |
  33188. * | FOGMODE_NONE | 0 |
  33189. * | FOGMODE_EXP | 1 |
  33190. * | FOGMODE_EXP2 | 2 |
  33191. * | FOGMODE_LINEAR | 3 |
  33192. */
  33193. fogMode: number;
  33194. /**
  33195. * Gets or sets the fog color to use
  33196. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33197. * (Default is Color3(0.2, 0.2, 0.3))
  33198. */
  33199. fogColor: Color3;
  33200. /**
  33201. * Gets or sets the fog density to use
  33202. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33203. * (Default is 0.1)
  33204. */
  33205. fogDensity: number;
  33206. /**
  33207. * Gets or sets the fog start distance to use
  33208. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33209. * (Default is 0)
  33210. */
  33211. fogStart: number;
  33212. /**
  33213. * Gets or sets the fog end distance to use
  33214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33215. * (Default is 1000)
  33216. */
  33217. fogEnd: number;
  33218. private _shadowsEnabled;
  33219. /**
  33220. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33221. */
  33222. shadowsEnabled: boolean;
  33223. private _lightsEnabled;
  33224. /**
  33225. * Gets or sets a boolean indicating if lights are enabled on this scene
  33226. */
  33227. lightsEnabled: boolean;
  33228. /** All of the active cameras added to this scene. */
  33229. activeCameras: Camera[];
  33230. /** @hidden */
  33231. _activeCamera: Nullable<Camera>;
  33232. /** Gets or sets the current active camera */
  33233. activeCamera: Nullable<Camera>;
  33234. private _defaultMaterial;
  33235. /** The default material used on meshes when no material is affected */
  33236. /** The default material used on meshes when no material is affected */
  33237. defaultMaterial: Material;
  33238. private _texturesEnabled;
  33239. /**
  33240. * Gets or sets a boolean indicating if textures are enabled on this scene
  33241. */
  33242. texturesEnabled: boolean;
  33243. /**
  33244. * Gets or sets a boolean indicating if particles are enabled on this scene
  33245. */
  33246. particlesEnabled: boolean;
  33247. /**
  33248. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33249. */
  33250. spritesEnabled: boolean;
  33251. private _skeletonsEnabled;
  33252. /**
  33253. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33254. */
  33255. skeletonsEnabled: boolean;
  33256. /**
  33257. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33258. */
  33259. lensFlaresEnabled: boolean;
  33260. /**
  33261. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33263. */
  33264. collisionsEnabled: boolean;
  33265. private _collisionCoordinator;
  33266. /** @hidden */
  33267. readonly collisionCoordinator: ICollisionCoordinator;
  33268. /**
  33269. * Defines the gravity applied to this scene (used only for collisions)
  33270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33271. */
  33272. gravity: Vector3;
  33273. /**
  33274. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33275. */
  33276. postProcessesEnabled: boolean;
  33277. /**
  33278. * The list of postprocesses added to the scene
  33279. */
  33280. postProcesses: PostProcess[];
  33281. /**
  33282. * Gets the current postprocess manager
  33283. */
  33284. postProcessManager: PostProcessManager;
  33285. /**
  33286. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33287. */
  33288. renderTargetsEnabled: boolean;
  33289. /**
  33290. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33291. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33292. */
  33293. dumpNextRenderTargets: boolean;
  33294. /**
  33295. * The list of user defined render targets added to the scene
  33296. */
  33297. customRenderTargets: RenderTargetTexture[];
  33298. /**
  33299. * Defines if texture loading must be delayed
  33300. * If true, textures will only be loaded when they need to be rendered
  33301. */
  33302. useDelayedTextureLoading: boolean;
  33303. /**
  33304. * Gets the list of meshes imported to the scene through SceneLoader
  33305. */
  33306. importedMeshesFiles: String[];
  33307. /**
  33308. * Gets or sets a boolean indicating if probes are enabled on this scene
  33309. */
  33310. probesEnabled: boolean;
  33311. /**
  33312. * Gets or sets the current offline provider to use to store scene data
  33313. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33314. */
  33315. offlineProvider: IOfflineProvider;
  33316. /**
  33317. * Gets or sets the action manager associated with the scene
  33318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33319. */
  33320. actionManager: AbstractActionManager;
  33321. private _meshesForIntersections;
  33322. /**
  33323. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33324. */
  33325. proceduralTexturesEnabled: boolean;
  33326. private _engine;
  33327. private _totalVertices;
  33328. /** @hidden */
  33329. _activeIndices: PerfCounter;
  33330. /** @hidden */
  33331. _activeParticles: PerfCounter;
  33332. /** @hidden */
  33333. _activeBones: PerfCounter;
  33334. private _animationRatio;
  33335. /** @hidden */
  33336. _animationTimeLast: number;
  33337. /** @hidden */
  33338. _animationTime: number;
  33339. /**
  33340. * Gets or sets a general scale for animation speed
  33341. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33342. */
  33343. animationTimeScale: number;
  33344. /** @hidden */
  33345. _cachedMaterial: Nullable<Material>;
  33346. /** @hidden */
  33347. _cachedEffect: Nullable<Effect>;
  33348. /** @hidden */
  33349. _cachedVisibility: Nullable<number>;
  33350. private _renderId;
  33351. private _frameId;
  33352. private _executeWhenReadyTimeoutId;
  33353. private _intermediateRendering;
  33354. private _viewUpdateFlag;
  33355. private _projectionUpdateFlag;
  33356. /** @hidden */
  33357. _toBeDisposed: Nullable<IDisposable>[];
  33358. private _activeRequests;
  33359. /** @hidden */
  33360. _pendingData: any[];
  33361. private _isDisposed;
  33362. /**
  33363. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33364. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33365. */
  33366. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33367. private _activeMeshes;
  33368. private _processedMaterials;
  33369. private _renderTargets;
  33370. /** @hidden */
  33371. _activeParticleSystems: SmartArray<IParticleSystem>;
  33372. private _activeSkeletons;
  33373. private _softwareSkinnedMeshes;
  33374. private _renderingManager;
  33375. /** @hidden */
  33376. _activeAnimatables: Animatable[];
  33377. private _transformMatrix;
  33378. private _sceneUbo;
  33379. /** @hidden */
  33380. _viewMatrix: Matrix;
  33381. private _projectionMatrix;
  33382. /** @hidden */
  33383. _forcedViewPosition: Nullable<Vector3>;
  33384. /** @hidden */
  33385. _frustumPlanes: Plane[];
  33386. /**
  33387. * Gets the list of frustum planes (built from the active camera)
  33388. */
  33389. readonly frustumPlanes: Plane[];
  33390. /**
  33391. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33392. * This is useful if there are more lights that the maximum simulteanous authorized
  33393. */
  33394. requireLightSorting: boolean;
  33395. /** @hidden */
  33396. readonly useMaterialMeshMap: boolean;
  33397. /** @hidden */
  33398. readonly useClonedMeshhMap: boolean;
  33399. private _externalData;
  33400. private _uid;
  33401. /**
  33402. * @hidden
  33403. * Backing store of defined scene components.
  33404. */
  33405. _components: ISceneComponent[];
  33406. /**
  33407. * @hidden
  33408. * Backing store of defined scene components.
  33409. */
  33410. _serializableComponents: ISceneSerializableComponent[];
  33411. /**
  33412. * List of components to register on the next registration step.
  33413. */
  33414. private _transientComponents;
  33415. /**
  33416. * Registers the transient components if needed.
  33417. */
  33418. private _registerTransientComponents;
  33419. /**
  33420. * @hidden
  33421. * Add a component to the scene.
  33422. * Note that the ccomponent could be registered on th next frame if this is called after
  33423. * the register component stage.
  33424. * @param component Defines the component to add to the scene
  33425. */
  33426. _addComponent(component: ISceneComponent): void;
  33427. /**
  33428. * @hidden
  33429. * Gets a component from the scene.
  33430. * @param name defines the name of the component to retrieve
  33431. * @returns the component or null if not present
  33432. */
  33433. _getComponent(name: string): Nullable<ISceneComponent>;
  33434. /**
  33435. * @hidden
  33436. * Defines the actions happening before camera updates.
  33437. */
  33438. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33439. /**
  33440. * @hidden
  33441. * Defines the actions happening before clear the canvas.
  33442. */
  33443. _beforeClearStage: Stage<SimpleStageAction>;
  33444. /**
  33445. * @hidden
  33446. * Defines the actions when collecting render targets for the frame.
  33447. */
  33448. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33449. /**
  33450. * @hidden
  33451. * Defines the actions happening for one camera in the frame.
  33452. */
  33453. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33454. /**
  33455. * @hidden
  33456. * Defines the actions happening during the per mesh ready checks.
  33457. */
  33458. _isReadyForMeshStage: Stage<MeshStageAction>;
  33459. /**
  33460. * @hidden
  33461. * Defines the actions happening before evaluate active mesh checks.
  33462. */
  33463. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33464. /**
  33465. * @hidden
  33466. * Defines the actions happening during the evaluate sub mesh checks.
  33467. */
  33468. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33469. /**
  33470. * @hidden
  33471. * Defines the actions happening during the active mesh stage.
  33472. */
  33473. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33474. /**
  33475. * @hidden
  33476. * Defines the actions happening during the per camera render target step.
  33477. */
  33478. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33479. /**
  33480. * @hidden
  33481. * Defines the actions happening just before the active camera is drawing.
  33482. */
  33483. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33484. /**
  33485. * @hidden
  33486. * Defines the actions happening just before a render target is drawing.
  33487. */
  33488. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33489. /**
  33490. * @hidden
  33491. * Defines the actions happening just before a rendering group is drawing.
  33492. */
  33493. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33494. /**
  33495. * @hidden
  33496. * Defines the actions happening just before a mesh is drawing.
  33497. */
  33498. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33499. /**
  33500. * @hidden
  33501. * Defines the actions happening just after a mesh has been drawn.
  33502. */
  33503. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33504. /**
  33505. * @hidden
  33506. * Defines the actions happening just after a rendering group has been drawn.
  33507. */
  33508. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33509. /**
  33510. * @hidden
  33511. * Defines the actions happening just after the active camera has been drawn.
  33512. */
  33513. _afterCameraDrawStage: Stage<CameraStageAction>;
  33514. /**
  33515. * @hidden
  33516. * Defines the actions happening just after a render target has been drawn.
  33517. */
  33518. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33519. /**
  33520. * @hidden
  33521. * Defines the actions happening just after rendering all cameras and computing intersections.
  33522. */
  33523. _afterRenderStage: Stage<SimpleStageAction>;
  33524. /**
  33525. * @hidden
  33526. * Defines the actions happening when a pointer move event happens.
  33527. */
  33528. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33529. /**
  33530. * @hidden
  33531. * Defines the actions happening when a pointer down event happens.
  33532. */
  33533. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33534. /**
  33535. * @hidden
  33536. * Defines the actions happening when a pointer up event happens.
  33537. */
  33538. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33539. /**
  33540. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33541. */
  33542. private geometriesByUniqueId;
  33543. /**
  33544. * Creates a new Scene
  33545. * @param engine defines the engine to use to render this scene
  33546. * @param options defines the scene options
  33547. */
  33548. constructor(engine: Engine, options?: SceneOptions);
  33549. /**
  33550. * Gets a string idenfifying the name of the class
  33551. * @returns "Scene" string
  33552. */
  33553. getClassName(): string;
  33554. private _defaultMeshCandidates;
  33555. /**
  33556. * @hidden
  33557. */
  33558. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33559. private _defaultSubMeshCandidates;
  33560. /**
  33561. * @hidden
  33562. */
  33563. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33564. /**
  33565. * Sets the default candidate providers for the scene.
  33566. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33567. * and getCollidingSubMeshCandidates to their default function
  33568. */
  33569. setDefaultCandidateProviders(): void;
  33570. /**
  33571. * Gets the mesh that is currently under the pointer
  33572. */
  33573. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33574. /**
  33575. * Gets or sets the current on-screen X position of the pointer
  33576. */
  33577. pointerX: number;
  33578. /**
  33579. * Gets or sets the current on-screen Y position of the pointer
  33580. */
  33581. pointerY: number;
  33582. /**
  33583. * Gets the cached material (ie. the latest rendered one)
  33584. * @returns the cached material
  33585. */
  33586. getCachedMaterial(): Nullable<Material>;
  33587. /**
  33588. * Gets the cached effect (ie. the latest rendered one)
  33589. * @returns the cached effect
  33590. */
  33591. getCachedEffect(): Nullable<Effect>;
  33592. /**
  33593. * Gets the cached visibility state (ie. the latest rendered one)
  33594. * @returns the cached visibility state
  33595. */
  33596. getCachedVisibility(): Nullable<number>;
  33597. /**
  33598. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33599. * @param material defines the current material
  33600. * @param effect defines the current effect
  33601. * @param visibility defines the current visibility state
  33602. * @returns true if one parameter is not cached
  33603. */
  33604. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33605. /**
  33606. * Gets the engine associated with the scene
  33607. * @returns an Engine
  33608. */
  33609. getEngine(): Engine;
  33610. /**
  33611. * Gets the total number of vertices rendered per frame
  33612. * @returns the total number of vertices rendered per frame
  33613. */
  33614. getTotalVertices(): number;
  33615. /**
  33616. * Gets the performance counter for total vertices
  33617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33618. */
  33619. readonly totalVerticesPerfCounter: PerfCounter;
  33620. /**
  33621. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33622. * @returns the total number of active indices rendered per frame
  33623. */
  33624. getActiveIndices(): number;
  33625. /**
  33626. * Gets the performance counter for active indices
  33627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33628. */
  33629. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33630. /**
  33631. * Gets the total number of active particles rendered per frame
  33632. * @returns the total number of active particles rendered per frame
  33633. */
  33634. getActiveParticles(): number;
  33635. /**
  33636. * Gets the performance counter for active particles
  33637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33638. */
  33639. readonly activeParticlesPerfCounter: PerfCounter;
  33640. /**
  33641. * Gets the total number of active bones rendered per frame
  33642. * @returns the total number of active bones rendered per frame
  33643. */
  33644. getActiveBones(): number;
  33645. /**
  33646. * Gets the performance counter for active bones
  33647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33648. */
  33649. readonly activeBonesPerfCounter: PerfCounter;
  33650. /**
  33651. * Gets the array of active meshes
  33652. * @returns an array of AbstractMesh
  33653. */
  33654. getActiveMeshes(): SmartArray<AbstractMesh>;
  33655. /**
  33656. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33657. * @returns a number
  33658. */
  33659. getAnimationRatio(): number;
  33660. /**
  33661. * Gets an unique Id for the current render phase
  33662. * @returns a number
  33663. */
  33664. getRenderId(): number;
  33665. /**
  33666. * Gets an unique Id for the current frame
  33667. * @returns a number
  33668. */
  33669. getFrameId(): number;
  33670. /** Call this function if you want to manually increment the render Id*/
  33671. incrementRenderId(): void;
  33672. private _createUbo;
  33673. /**
  33674. * Use this method to simulate a pointer move on a mesh
  33675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33678. * @returns the current scene
  33679. */
  33680. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33681. /**
  33682. * Use this method to simulate a pointer down on a mesh
  33683. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33684. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33685. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33686. * @returns the current scene
  33687. */
  33688. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33689. /**
  33690. * Use this method to simulate a pointer up on a mesh
  33691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33694. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33695. * @returns the current scene
  33696. */
  33697. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33698. /**
  33699. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33700. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33701. * @returns true if the pointer was captured
  33702. */
  33703. isPointerCaptured(pointerId?: number): boolean;
  33704. /**
  33705. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33706. * @param attachUp defines if you want to attach events to pointerup
  33707. * @param attachDown defines if you want to attach events to pointerdown
  33708. * @param attachMove defines if you want to attach events to pointermove
  33709. */
  33710. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33711. /** Detaches all event handlers*/
  33712. detachControl(): void;
  33713. /**
  33714. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33715. * Delay loaded resources are not taking in account
  33716. * @return true if all required resources are ready
  33717. */
  33718. isReady(): boolean;
  33719. /** Resets all cached information relative to material (including effect and visibility) */
  33720. resetCachedMaterial(): void;
  33721. /**
  33722. * Registers a function to be called before every frame render
  33723. * @param func defines the function to register
  33724. */
  33725. registerBeforeRender(func: () => void): void;
  33726. /**
  33727. * Unregisters a function called before every frame render
  33728. * @param func defines the function to unregister
  33729. */
  33730. unregisterBeforeRender(func: () => void): void;
  33731. /**
  33732. * Registers a function to be called after every frame render
  33733. * @param func defines the function to register
  33734. */
  33735. registerAfterRender(func: () => void): void;
  33736. /**
  33737. * Unregisters a function called after every frame render
  33738. * @param func defines the function to unregister
  33739. */
  33740. unregisterAfterRender(func: () => void): void;
  33741. private _executeOnceBeforeRender;
  33742. /**
  33743. * The provided function will run before render once and will be disposed afterwards.
  33744. * A timeout delay can be provided so that the function will be executed in N ms.
  33745. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33746. * @param func The function to be executed.
  33747. * @param timeout optional delay in ms
  33748. */
  33749. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33750. /** @hidden */
  33751. _addPendingData(data: any): void;
  33752. /** @hidden */
  33753. _removePendingData(data: any): void;
  33754. /**
  33755. * Returns the number of items waiting to be loaded
  33756. * @returns the number of items waiting to be loaded
  33757. */
  33758. getWaitingItemsCount(): number;
  33759. /**
  33760. * Returns a boolean indicating if the scene is still loading data
  33761. */
  33762. readonly isLoading: boolean;
  33763. /**
  33764. * Registers a function to be executed when the scene is ready
  33765. * @param {Function} func - the function to be executed
  33766. */
  33767. executeWhenReady(func: () => void): void;
  33768. /**
  33769. * Returns a promise that resolves when the scene is ready
  33770. * @returns A promise that resolves when the scene is ready
  33771. */
  33772. whenReadyAsync(): Promise<void>;
  33773. /** @hidden */
  33774. _checkIsReady(): void;
  33775. /**
  33776. * Gets all animatable attached to the scene
  33777. */
  33778. readonly animatables: Animatable[];
  33779. /**
  33780. * Resets the last animation time frame.
  33781. * Useful to override when animations start running when loading a scene for the first time.
  33782. */
  33783. resetLastAnimationTimeFrame(): void;
  33784. /**
  33785. * Gets the current view matrix
  33786. * @returns a Matrix
  33787. */
  33788. getViewMatrix(): Matrix;
  33789. /**
  33790. * Gets the current projection matrix
  33791. * @returns a Matrix
  33792. */
  33793. getProjectionMatrix(): Matrix;
  33794. /**
  33795. * Gets the current transform matrix
  33796. * @returns a Matrix made of View * Projection
  33797. */
  33798. getTransformMatrix(): Matrix;
  33799. /**
  33800. * Sets the current transform matrix
  33801. * @param viewL defines the View matrix to use
  33802. * @param projectionL defines the Projection matrix to use
  33803. * @param viewR defines the right View matrix to use (if provided)
  33804. * @param projectionR defines the right Projection matrix to use (if provided)
  33805. */
  33806. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33807. /**
  33808. * Gets the uniform buffer used to store scene data
  33809. * @returns a UniformBuffer
  33810. */
  33811. getSceneUniformBuffer(): UniformBuffer;
  33812. /**
  33813. * Gets an unique (relatively to the current scene) Id
  33814. * @returns an unique number for the scene
  33815. */
  33816. getUniqueId(): number;
  33817. /**
  33818. * Add a mesh to the list of scene's meshes
  33819. * @param newMesh defines the mesh to add
  33820. * @param recursive if all child meshes should also be added to the scene
  33821. */
  33822. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33823. /**
  33824. * Remove a mesh for the list of scene's meshes
  33825. * @param toRemove defines the mesh to remove
  33826. * @param recursive if all child meshes should also be removed from the scene
  33827. * @returns the index where the mesh was in the mesh list
  33828. */
  33829. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33830. /**
  33831. * Add a transform node to the list of scene's transform nodes
  33832. * @param newTransformNode defines the transform node to add
  33833. */
  33834. addTransformNode(newTransformNode: TransformNode): void;
  33835. /**
  33836. * Remove a transform node for the list of scene's transform nodes
  33837. * @param toRemove defines the transform node to remove
  33838. * @returns the index where the transform node was in the transform node list
  33839. */
  33840. removeTransformNode(toRemove: TransformNode): number;
  33841. /**
  33842. * Remove a skeleton for the list of scene's skeletons
  33843. * @param toRemove defines the skeleton to remove
  33844. * @returns the index where the skeleton was in the skeleton list
  33845. */
  33846. removeSkeleton(toRemove: Skeleton): number;
  33847. /**
  33848. * Remove a morph target for the list of scene's morph targets
  33849. * @param toRemove defines the morph target to remove
  33850. * @returns the index where the morph target was in the morph target list
  33851. */
  33852. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33853. /**
  33854. * Remove a light for the list of scene's lights
  33855. * @param toRemove defines the light to remove
  33856. * @returns the index where the light was in the light list
  33857. */
  33858. removeLight(toRemove: Light): number;
  33859. /**
  33860. * Remove a camera for the list of scene's cameras
  33861. * @param toRemove defines the camera to remove
  33862. * @returns the index where the camera was in the camera list
  33863. */
  33864. removeCamera(toRemove: Camera): number;
  33865. /**
  33866. * Remove a particle system for the list of scene's particle systems
  33867. * @param toRemove defines the particle system to remove
  33868. * @returns the index where the particle system was in the particle system list
  33869. */
  33870. removeParticleSystem(toRemove: IParticleSystem): number;
  33871. /**
  33872. * Remove a animation for the list of scene's animations
  33873. * @param toRemove defines the animation to remove
  33874. * @returns the index where the animation was in the animation list
  33875. */
  33876. removeAnimation(toRemove: Animation): number;
  33877. /**
  33878. * Will stop the animation of the given target
  33879. * @param target - the target
  33880. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33881. * @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)
  33882. */
  33883. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33884. /**
  33885. * Removes the given animation group from this scene.
  33886. * @param toRemove The animation group to remove
  33887. * @returns The index of the removed animation group
  33888. */
  33889. removeAnimationGroup(toRemove: AnimationGroup): number;
  33890. /**
  33891. * Removes the given multi-material from this scene.
  33892. * @param toRemove The multi-material to remove
  33893. * @returns The index of the removed multi-material
  33894. */
  33895. removeMultiMaterial(toRemove: MultiMaterial): number;
  33896. /**
  33897. * Removes the given material from this scene.
  33898. * @param toRemove The material to remove
  33899. * @returns The index of the removed material
  33900. */
  33901. removeMaterial(toRemove: Material): number;
  33902. /**
  33903. * Removes the given action manager from this scene.
  33904. * @param toRemove The action manager to remove
  33905. * @returns The index of the removed action manager
  33906. */
  33907. removeActionManager(toRemove: AbstractActionManager): number;
  33908. /**
  33909. * Removes the given texture from this scene.
  33910. * @param toRemove The texture to remove
  33911. * @returns The index of the removed texture
  33912. */
  33913. removeTexture(toRemove: BaseTexture): number;
  33914. /**
  33915. * Adds the given light to this scene
  33916. * @param newLight The light to add
  33917. */
  33918. addLight(newLight: Light): void;
  33919. /**
  33920. * Sorts the list list based on light priorities
  33921. */
  33922. sortLightsByPriority(): void;
  33923. /**
  33924. * Adds the given camera to this scene
  33925. * @param newCamera The camera to add
  33926. */
  33927. addCamera(newCamera: Camera): void;
  33928. /**
  33929. * Adds the given skeleton to this scene
  33930. * @param newSkeleton The skeleton to add
  33931. */
  33932. addSkeleton(newSkeleton: Skeleton): void;
  33933. /**
  33934. * Adds the given particle system to this scene
  33935. * @param newParticleSystem The particle system to add
  33936. */
  33937. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33938. /**
  33939. * Adds the given animation to this scene
  33940. * @param newAnimation The animation to add
  33941. */
  33942. addAnimation(newAnimation: Animation): void;
  33943. /**
  33944. * Adds the given animation group to this scene.
  33945. * @param newAnimationGroup The animation group to add
  33946. */
  33947. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33948. /**
  33949. * Adds the given multi-material to this scene
  33950. * @param newMultiMaterial The multi-material to add
  33951. */
  33952. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33953. /**
  33954. * Adds the given material to this scene
  33955. * @param newMaterial The material to add
  33956. */
  33957. addMaterial(newMaterial: Material): void;
  33958. /**
  33959. * Adds the given morph target to this scene
  33960. * @param newMorphTargetManager The morph target to add
  33961. */
  33962. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33963. /**
  33964. * Adds the given geometry to this scene
  33965. * @param newGeometry The geometry to add
  33966. */
  33967. addGeometry(newGeometry: Geometry): void;
  33968. /**
  33969. * Adds the given action manager to this scene
  33970. * @param newActionManager The action manager to add
  33971. */
  33972. addActionManager(newActionManager: AbstractActionManager): void;
  33973. /**
  33974. * Adds the given texture to this scene.
  33975. * @param newTexture The texture to add
  33976. */
  33977. addTexture(newTexture: BaseTexture): void;
  33978. /**
  33979. * Switch active camera
  33980. * @param newCamera defines the new active camera
  33981. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33982. */
  33983. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33984. /**
  33985. * sets the active camera of the scene using its ID
  33986. * @param id defines the camera's ID
  33987. * @return the new active camera or null if none found.
  33988. */
  33989. setActiveCameraByID(id: string): Nullable<Camera>;
  33990. /**
  33991. * sets the active camera of the scene using its name
  33992. * @param name defines the camera's name
  33993. * @returns the new active camera or null if none found.
  33994. */
  33995. setActiveCameraByName(name: string): Nullable<Camera>;
  33996. /**
  33997. * get an animation group using its name
  33998. * @param name defines the material's name
  33999. * @return the animation group or null if none found.
  34000. */
  34001. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34002. /**
  34003. * Get a material using its unique id
  34004. * @param uniqueId defines the material's unique id
  34005. * @return the material or null if none found.
  34006. */
  34007. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34008. /**
  34009. * get a material using its id
  34010. * @param id defines the material's ID
  34011. * @return the material or null if none found.
  34012. */
  34013. getMaterialByID(id: string): Nullable<Material>;
  34014. /**
  34015. * Gets a the last added material using a given id
  34016. * @param id defines the material's ID
  34017. * @return the last material with the given id or null if none found.
  34018. */
  34019. getLastMaterialByID(id: string): Nullable<Material>;
  34020. /**
  34021. * Gets a material using its name
  34022. * @param name defines the material's name
  34023. * @return the material or null if none found.
  34024. */
  34025. getMaterialByName(name: string): Nullable<Material>;
  34026. /**
  34027. * Get a texture using its unique id
  34028. * @param uniqueId defines the texture's unique id
  34029. * @return the texture or null if none found.
  34030. */
  34031. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34032. /**
  34033. * Gets a camera using its id
  34034. * @param id defines the id to look for
  34035. * @returns the camera or null if not found
  34036. */
  34037. getCameraByID(id: string): Nullable<Camera>;
  34038. /**
  34039. * Gets a camera using its unique id
  34040. * @param uniqueId defines the unique id to look for
  34041. * @returns the camera or null if not found
  34042. */
  34043. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34044. /**
  34045. * Gets a camera using its name
  34046. * @param name defines the camera's name
  34047. * @return the camera or null if none found.
  34048. */
  34049. getCameraByName(name: string): Nullable<Camera>;
  34050. /**
  34051. * Gets a bone using its id
  34052. * @param id defines the bone's id
  34053. * @return the bone or null if not found
  34054. */
  34055. getBoneByID(id: string): Nullable<Bone>;
  34056. /**
  34057. * Gets a bone using its id
  34058. * @param name defines the bone's name
  34059. * @return the bone or null if not found
  34060. */
  34061. getBoneByName(name: string): Nullable<Bone>;
  34062. /**
  34063. * Gets a light node using its name
  34064. * @param name defines the the light's name
  34065. * @return the light or null if none found.
  34066. */
  34067. getLightByName(name: string): Nullable<Light>;
  34068. /**
  34069. * Gets a light node using its id
  34070. * @param id defines the light's id
  34071. * @return the light or null if none found.
  34072. */
  34073. getLightByID(id: string): Nullable<Light>;
  34074. /**
  34075. * Gets a light node using its scene-generated unique ID
  34076. * @param uniqueId defines the light's unique id
  34077. * @return the light or null if none found.
  34078. */
  34079. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34080. /**
  34081. * Gets a particle system by id
  34082. * @param id defines the particle system id
  34083. * @return the corresponding system or null if none found
  34084. */
  34085. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34086. /**
  34087. * Gets a geometry using its ID
  34088. * @param id defines the geometry's id
  34089. * @return the geometry or null if none found.
  34090. */
  34091. getGeometryByID(id: string): Nullable<Geometry>;
  34092. private _getGeometryByUniqueID;
  34093. /**
  34094. * Add a new geometry to this scene
  34095. * @param geometry defines the geometry to be added to the scene.
  34096. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34097. * @return a boolean defining if the geometry was added or not
  34098. */
  34099. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34100. /**
  34101. * Removes an existing geometry
  34102. * @param geometry defines the geometry to be removed from the scene
  34103. * @return a boolean defining if the geometry was removed or not
  34104. */
  34105. removeGeometry(geometry: Geometry): boolean;
  34106. /**
  34107. * Gets the list of geometries attached to the scene
  34108. * @returns an array of Geometry
  34109. */
  34110. getGeometries(): Geometry[];
  34111. /**
  34112. * Gets the first added mesh found of a given ID
  34113. * @param id defines the id to search for
  34114. * @return the mesh found or null if not found at all
  34115. */
  34116. getMeshByID(id: string): Nullable<AbstractMesh>;
  34117. /**
  34118. * Gets a list of meshes using their id
  34119. * @param id defines the id to search for
  34120. * @returns a list of meshes
  34121. */
  34122. getMeshesByID(id: string): Array<AbstractMesh>;
  34123. /**
  34124. * Gets the first added transform node found of a given ID
  34125. * @param id defines the id to search for
  34126. * @return the found transform node or null if not found at all.
  34127. */
  34128. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34129. /**
  34130. * Gets a transform node with its auto-generated unique id
  34131. * @param uniqueId efines the unique id to search for
  34132. * @return the found transform node or null if not found at all.
  34133. */
  34134. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34135. /**
  34136. * Gets a list of transform nodes using their id
  34137. * @param id defines the id to search for
  34138. * @returns a list of transform nodes
  34139. */
  34140. getTransformNodesByID(id: string): Array<TransformNode>;
  34141. /**
  34142. * Gets a mesh with its auto-generated unique id
  34143. * @param uniqueId defines the unique id to search for
  34144. * @return the found mesh or null if not found at all.
  34145. */
  34146. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34147. /**
  34148. * Gets a the last added mesh using a given id
  34149. * @param id defines the id to search for
  34150. * @return the found mesh or null if not found at all.
  34151. */
  34152. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34153. /**
  34154. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34155. * @param id defines the id to search for
  34156. * @return the found node or null if not found at all
  34157. */
  34158. getLastEntryByID(id: string): Nullable<Node>;
  34159. /**
  34160. * Gets a node (Mesh, Camera, Light) using a given id
  34161. * @param id defines the id to search for
  34162. * @return the found node or null if not found at all
  34163. */
  34164. getNodeByID(id: string): Nullable<Node>;
  34165. /**
  34166. * Gets a node (Mesh, Camera, Light) using a given name
  34167. * @param name defines the name to search for
  34168. * @return the found node or null if not found at all.
  34169. */
  34170. getNodeByName(name: string): Nullable<Node>;
  34171. /**
  34172. * Gets a mesh using a given name
  34173. * @param name defines the name to search for
  34174. * @return the found mesh or null if not found at all.
  34175. */
  34176. getMeshByName(name: string): Nullable<AbstractMesh>;
  34177. /**
  34178. * Gets a transform node using a given name
  34179. * @param name defines the name to search for
  34180. * @return the found transform node or null if not found at all.
  34181. */
  34182. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34183. /**
  34184. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34185. * @param id defines the id to search for
  34186. * @return the found skeleton or null if not found at all.
  34187. */
  34188. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34189. /**
  34190. * Gets a skeleton using a given auto generated unique id
  34191. * @param uniqueId defines the unique id to search for
  34192. * @return the found skeleton or null if not found at all.
  34193. */
  34194. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34195. /**
  34196. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34197. * @param id defines the id to search for
  34198. * @return the found skeleton or null if not found at all.
  34199. */
  34200. getSkeletonById(id: string): Nullable<Skeleton>;
  34201. /**
  34202. * Gets a skeleton using a given name
  34203. * @param name defines the name to search for
  34204. * @return the found skeleton or null if not found at all.
  34205. */
  34206. getSkeletonByName(name: string): Nullable<Skeleton>;
  34207. /**
  34208. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34209. * @param id defines the id to search for
  34210. * @return the found morph target manager or null if not found at all.
  34211. */
  34212. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34213. /**
  34214. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34215. * @param id defines the id to search for
  34216. * @return the found morph target or null if not found at all.
  34217. */
  34218. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34219. /**
  34220. * Gets a boolean indicating if the given mesh is active
  34221. * @param mesh defines the mesh to look for
  34222. * @returns true if the mesh is in the active list
  34223. */
  34224. isActiveMesh(mesh: AbstractMesh): boolean;
  34225. /**
  34226. * Return a unique id as a string which can serve as an identifier for the scene
  34227. */
  34228. readonly uid: string;
  34229. /**
  34230. * Add an externaly attached data from its key.
  34231. * This method call will fail and return false, if such key already exists.
  34232. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34233. * @param key the unique key that identifies the data
  34234. * @param data the data object to associate to the key for this Engine instance
  34235. * @return true if no such key were already present and the data was added successfully, false otherwise
  34236. */
  34237. addExternalData<T>(key: string, data: T): boolean;
  34238. /**
  34239. * Get an externaly attached data from its key
  34240. * @param key the unique key that identifies the data
  34241. * @return the associated data, if present (can be null), or undefined if not present
  34242. */
  34243. getExternalData<T>(key: string): Nullable<T>;
  34244. /**
  34245. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34246. * @param key the unique key that identifies the data
  34247. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34248. * @return the associated data, can be null if the factory returned null.
  34249. */
  34250. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34251. /**
  34252. * Remove an externaly attached data from the Engine instance
  34253. * @param key the unique key that identifies the data
  34254. * @return true if the data was successfully removed, false if it doesn't exist
  34255. */
  34256. removeExternalData(key: string): boolean;
  34257. private _evaluateSubMesh;
  34258. /**
  34259. * Clear the processed materials smart array preventing retention point in material dispose.
  34260. */
  34261. freeProcessedMaterials(): void;
  34262. private _preventFreeActiveMeshesAndRenderingGroups;
  34263. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34264. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34265. * when disposing several meshes in a row or a hierarchy of meshes.
  34266. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34267. */
  34268. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34269. /**
  34270. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34271. */
  34272. freeActiveMeshes(): void;
  34273. /**
  34274. * Clear the info related to rendering groups preventing retention points during dispose.
  34275. */
  34276. freeRenderingGroups(): void;
  34277. /** @hidden */
  34278. _isInIntermediateRendering(): boolean;
  34279. /**
  34280. * Lambda returning the list of potentially active meshes.
  34281. */
  34282. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34283. /**
  34284. * Lambda returning the list of potentially active sub meshes.
  34285. */
  34286. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34287. /**
  34288. * Lambda returning the list of potentially intersecting sub meshes.
  34289. */
  34290. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34291. /**
  34292. * Lambda returning the list of potentially colliding sub meshes.
  34293. */
  34294. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34295. private _activeMeshesFrozen;
  34296. /**
  34297. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34298. * @returns the current scene
  34299. */
  34300. freezeActiveMeshes(): Scene;
  34301. /**
  34302. * Use this function to restart evaluating active meshes on every frame
  34303. * @returns the current scene
  34304. */
  34305. unfreezeActiveMeshes(): Scene;
  34306. private _evaluateActiveMeshes;
  34307. private _activeMesh;
  34308. /**
  34309. * Update the transform matrix to update from the current active camera
  34310. * @param force defines a boolean used to force the update even if cache is up to date
  34311. */
  34312. updateTransformMatrix(force?: boolean): void;
  34313. private _bindFrameBuffer;
  34314. /** @hidden */
  34315. _allowPostProcessClearColor: boolean;
  34316. /** @hidden */
  34317. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34318. private _processSubCameras;
  34319. private _checkIntersections;
  34320. /** @hidden */
  34321. _advancePhysicsEngineStep(step: number): void;
  34322. /**
  34323. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34324. */
  34325. getDeterministicFrameTime: () => number;
  34326. /** @hidden */
  34327. _animate(): void;
  34328. /** Execute all animations (for a frame) */
  34329. animate(): void;
  34330. /**
  34331. * Render the scene
  34332. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34333. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34334. */
  34335. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34336. /**
  34337. * Freeze all materials
  34338. * A frozen material will not be updatable but should be faster to render
  34339. */
  34340. freezeMaterials(): void;
  34341. /**
  34342. * Unfreeze all materials
  34343. * A frozen material will not be updatable but should be faster to render
  34344. */
  34345. unfreezeMaterials(): void;
  34346. /**
  34347. * Releases all held ressources
  34348. */
  34349. dispose(): void;
  34350. /**
  34351. * Gets if the scene is already disposed
  34352. */
  34353. readonly isDisposed: boolean;
  34354. /**
  34355. * Call this function to reduce memory footprint of the scene.
  34356. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34357. */
  34358. clearCachedVertexData(): void;
  34359. /**
  34360. * This function will remove the local cached buffer data from texture.
  34361. * It will save memory but will prevent the texture from being rebuilt
  34362. */
  34363. cleanCachedTextureBuffer(): void;
  34364. /**
  34365. * Get the world extend vectors with an optional filter
  34366. *
  34367. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34368. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34369. */
  34370. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34371. min: Vector3;
  34372. max: Vector3;
  34373. };
  34374. /**
  34375. * Creates a ray that can be used to pick in the scene
  34376. * @param x defines the x coordinate of the origin (on-screen)
  34377. * @param y defines the y coordinate of the origin (on-screen)
  34378. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34379. * @param camera defines the camera to use for the picking
  34380. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34381. * @returns a Ray
  34382. */
  34383. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34384. /**
  34385. * Creates a ray that can be used to pick in the scene
  34386. * @param x defines the x coordinate of the origin (on-screen)
  34387. * @param y defines the y coordinate of the origin (on-screen)
  34388. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34389. * @param result defines the ray where to store the picking ray
  34390. * @param camera defines the camera to use for the picking
  34391. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34392. * @returns the current scene
  34393. */
  34394. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34395. /**
  34396. * Creates a ray that can be used to pick in the scene
  34397. * @param x defines the x coordinate of the origin (on-screen)
  34398. * @param y defines the y coordinate of the origin (on-screen)
  34399. * @param camera defines the camera to use for the picking
  34400. * @returns a Ray
  34401. */
  34402. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34403. /**
  34404. * Creates a ray that can be used to pick in the scene
  34405. * @param x defines the x coordinate of the origin (on-screen)
  34406. * @param y defines the y coordinate of the origin (on-screen)
  34407. * @param result defines the ray where to store the picking ray
  34408. * @param camera defines the camera to use for the picking
  34409. * @returns the current scene
  34410. */
  34411. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34412. /** Launch a ray to try to pick a mesh in the scene
  34413. * @param x position on screen
  34414. * @param y position on screen
  34415. * @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
  34416. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34417. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34419. * @returns a PickingInfo
  34420. */
  34421. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34422. /** Use the given ray to pick a mesh in the scene
  34423. * @param ray The ray to use to pick meshes
  34424. * @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
  34425. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34427. * @returns a PickingInfo
  34428. */
  34429. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34430. /**
  34431. * Launch a ray to try to pick a mesh in the scene
  34432. * @param x X position on screen
  34433. * @param y Y position on screen
  34434. * @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
  34435. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34437. * @returns an array of PickingInfo
  34438. */
  34439. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34440. /**
  34441. * Launch a ray to try to pick a mesh in the scene
  34442. * @param ray Ray to use
  34443. * @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
  34444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34445. * @returns an array of PickingInfo
  34446. */
  34447. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34448. /**
  34449. * Force the value of meshUnderPointer
  34450. * @param mesh defines the mesh to use
  34451. */
  34452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34453. /**
  34454. * Gets the mesh under the pointer
  34455. * @returns a Mesh or null if no mesh is under the pointer
  34456. */
  34457. getPointerOverMesh(): Nullable<AbstractMesh>;
  34458. /** @hidden */
  34459. _rebuildGeometries(): void;
  34460. /** @hidden */
  34461. _rebuildTextures(): void;
  34462. private _getByTags;
  34463. /**
  34464. * Get a list of meshes by tags
  34465. * @param tagsQuery defines the tags query to use
  34466. * @param forEach defines a predicate used to filter results
  34467. * @returns an array of Mesh
  34468. */
  34469. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34470. /**
  34471. * Get a list of cameras by tags
  34472. * @param tagsQuery defines the tags query to use
  34473. * @param forEach defines a predicate used to filter results
  34474. * @returns an array of Camera
  34475. */
  34476. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34477. /**
  34478. * Get a list of lights by tags
  34479. * @param tagsQuery defines the tags query to use
  34480. * @param forEach defines a predicate used to filter results
  34481. * @returns an array of Light
  34482. */
  34483. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34484. /**
  34485. * Get a list of materials by tags
  34486. * @param tagsQuery defines the tags query to use
  34487. * @param forEach defines a predicate used to filter results
  34488. * @returns an array of Material
  34489. */
  34490. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34491. /**
  34492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34493. * This allowed control for front to back rendering or reversly depending of the special needs.
  34494. *
  34495. * @param renderingGroupId The rendering group id corresponding to its index
  34496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34499. */
  34500. 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;
  34501. /**
  34502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34503. *
  34504. * @param renderingGroupId The rendering group id corresponding to its index
  34505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34508. */
  34509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34510. /**
  34511. * Gets the current auto clear configuration for one rendering group of the rendering
  34512. * manager.
  34513. * @param index the rendering group index to get the information for
  34514. * @returns The auto clear setup for the requested rendering group
  34515. */
  34516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34517. private _blockMaterialDirtyMechanism;
  34518. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34519. blockMaterialDirtyMechanism: boolean;
  34520. /**
  34521. * Will flag all materials as dirty to trigger new shader compilation
  34522. * @param flag defines the flag used to specify which material part must be marked as dirty
  34523. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34524. */
  34525. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34526. /** @hidden */
  34527. _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;
  34528. /** @hidden */
  34529. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34530. }
  34531. }
  34532. declare module BABYLON {
  34533. /**
  34534. * Set of assets to keep when moving a scene into an asset container.
  34535. */
  34536. export class KeepAssets extends AbstractScene {
  34537. }
  34538. /**
  34539. * Container with a set of assets that can be added or removed from a scene.
  34540. */
  34541. export class AssetContainer extends AbstractScene {
  34542. /**
  34543. * The scene the AssetContainer belongs to.
  34544. */
  34545. scene: Scene;
  34546. /**
  34547. * Instantiates an AssetContainer.
  34548. * @param scene The scene the AssetContainer belongs to.
  34549. */
  34550. constructor(scene: Scene);
  34551. /**
  34552. * Adds all the assets from the container to the scene.
  34553. */
  34554. addAllToScene(): void;
  34555. /**
  34556. * Removes all the assets in the container from the scene
  34557. */
  34558. removeAllFromScene(): void;
  34559. /**
  34560. * Disposes all the assets in the container
  34561. */
  34562. dispose(): void;
  34563. private _moveAssets;
  34564. /**
  34565. * Removes all the assets contained in the scene and adds them to the container.
  34566. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34567. */
  34568. moveAllFromScene(keepAssets?: KeepAssets): void;
  34569. /**
  34570. * 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.
  34571. * @returns the root mesh
  34572. */
  34573. createRootMesh(): Mesh;
  34574. }
  34575. }
  34576. declare module BABYLON {
  34577. /**
  34578. * Defines how the parser contract is defined.
  34579. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34580. */
  34581. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34582. /**
  34583. * Defines how the individual parser contract is defined.
  34584. * These parser can parse an individual asset
  34585. */
  34586. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34587. /**
  34588. * Base class of the scene acting as a container for the different elements composing a scene.
  34589. * This class is dynamically extended by the different components of the scene increasing
  34590. * flexibility and reducing coupling
  34591. */
  34592. export abstract class AbstractScene {
  34593. /**
  34594. * Stores the list of available parsers in the application.
  34595. */
  34596. private static _BabylonFileParsers;
  34597. /**
  34598. * Stores the list of available individual parsers in the application.
  34599. */
  34600. private static _IndividualBabylonFileParsers;
  34601. /**
  34602. * Adds a parser in the list of available ones
  34603. * @param name Defines the name of the parser
  34604. * @param parser Defines the parser to add
  34605. */
  34606. static AddParser(name: string, parser: BabylonFileParser): void;
  34607. /**
  34608. * Gets a general parser from the list of avaialble ones
  34609. * @param name Defines the name of the parser
  34610. * @returns the requested parser or null
  34611. */
  34612. static GetParser(name: string): Nullable<BabylonFileParser>;
  34613. /**
  34614. * Adds n individual parser in the list of available ones
  34615. * @param name Defines the name of the parser
  34616. * @param parser Defines the parser to add
  34617. */
  34618. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34619. /**
  34620. * Gets an individual parser from the list of avaialble ones
  34621. * @param name Defines the name of the parser
  34622. * @returns the requested parser or null
  34623. */
  34624. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34625. /**
  34626. * Parser json data and populate both a scene and its associated container object
  34627. * @param jsonData Defines the data to parse
  34628. * @param scene Defines the scene to parse the data for
  34629. * @param container Defines the container attached to the parsing sequence
  34630. * @param rootUrl Defines the root url of the data
  34631. */
  34632. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34633. /**
  34634. * Gets the list of root nodes (ie. nodes with no parent)
  34635. */
  34636. rootNodes: Node[];
  34637. /** All of the cameras added to this scene
  34638. * @see http://doc.babylonjs.com/babylon101/cameras
  34639. */
  34640. cameras: Camera[];
  34641. /**
  34642. * All of the lights added to this scene
  34643. * @see http://doc.babylonjs.com/babylon101/lights
  34644. */
  34645. lights: Light[];
  34646. /**
  34647. * All of the (abstract) meshes added to this scene
  34648. */
  34649. meshes: AbstractMesh[];
  34650. /**
  34651. * The list of skeletons added to the scene
  34652. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34653. */
  34654. skeletons: Skeleton[];
  34655. /**
  34656. * All of the particle systems added to this scene
  34657. * @see http://doc.babylonjs.com/babylon101/particles
  34658. */
  34659. particleSystems: IParticleSystem[];
  34660. /**
  34661. * Gets a list of Animations associated with the scene
  34662. */
  34663. animations: Animation[];
  34664. /**
  34665. * All of the animation groups added to this scene
  34666. * @see http://doc.babylonjs.com/how_to/group
  34667. */
  34668. animationGroups: AnimationGroup[];
  34669. /**
  34670. * All of the multi-materials added to this scene
  34671. * @see http://doc.babylonjs.com/how_to/multi_materials
  34672. */
  34673. multiMaterials: MultiMaterial[];
  34674. /**
  34675. * All of the materials added to this scene
  34676. * In the context of a Scene, it is not supposed to be modified manually.
  34677. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34678. * Note also that the order of the Material wihin the array is not significant and might change.
  34679. * @see http://doc.babylonjs.com/babylon101/materials
  34680. */
  34681. materials: Material[];
  34682. /**
  34683. * The list of morph target managers added to the scene
  34684. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34685. */
  34686. morphTargetManagers: MorphTargetManager[];
  34687. /**
  34688. * The list of geometries used in the scene.
  34689. */
  34690. geometries: Geometry[];
  34691. /**
  34692. * All of the tranform nodes added to this scene
  34693. * In the context of a Scene, it is not supposed to be modified manually.
  34694. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34695. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34696. * @see http://doc.babylonjs.com/how_to/transformnode
  34697. */
  34698. transformNodes: TransformNode[];
  34699. /**
  34700. * ActionManagers available on the scene.
  34701. */
  34702. actionManagers: AbstractActionManager[];
  34703. /**
  34704. * Textures to keep.
  34705. */
  34706. textures: BaseTexture[];
  34707. /**
  34708. * Environment texture for the scene
  34709. */
  34710. environmentTexture: Nullable<BaseTexture>;
  34711. }
  34712. }
  34713. declare module BABYLON {
  34714. /**
  34715. * Interface used to define options for Sound class
  34716. */
  34717. export interface ISoundOptions {
  34718. /**
  34719. * Does the sound autoplay once loaded.
  34720. */
  34721. autoplay?: boolean;
  34722. /**
  34723. * Does the sound loop after it finishes playing once.
  34724. */
  34725. loop?: boolean;
  34726. /**
  34727. * Sound's volume
  34728. */
  34729. volume?: number;
  34730. /**
  34731. * Is it a spatial sound?
  34732. */
  34733. spatialSound?: boolean;
  34734. /**
  34735. * Maximum distance to hear that sound
  34736. */
  34737. maxDistance?: number;
  34738. /**
  34739. * Uses user defined attenuation function
  34740. */
  34741. useCustomAttenuation?: boolean;
  34742. /**
  34743. * Define the roll off factor of spatial sounds.
  34744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34745. */
  34746. rolloffFactor?: number;
  34747. /**
  34748. * Define the reference distance the sound should be heard perfectly.
  34749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34750. */
  34751. refDistance?: number;
  34752. /**
  34753. * Define the distance attenuation model the sound will follow.
  34754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34755. */
  34756. distanceModel?: string;
  34757. /**
  34758. * Defines the playback speed (1 by default)
  34759. */
  34760. playbackRate?: number;
  34761. /**
  34762. * Defines if the sound is from a streaming source
  34763. */
  34764. streaming?: boolean;
  34765. /**
  34766. * Defines an optional length (in seconds) inside the sound file
  34767. */
  34768. length?: number;
  34769. /**
  34770. * Defines an optional offset (in seconds) inside the sound file
  34771. */
  34772. offset?: number;
  34773. /**
  34774. * If true, URLs will not be required to state the audio file codec to use.
  34775. */
  34776. skipCodecCheck?: boolean;
  34777. }
  34778. /**
  34779. * Defines a sound that can be played in the application.
  34780. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34782. */
  34783. export class Sound {
  34784. /**
  34785. * The name of the sound in the scene.
  34786. */
  34787. name: string;
  34788. /**
  34789. * Does the sound autoplay once loaded.
  34790. */
  34791. autoplay: boolean;
  34792. /**
  34793. * Does the sound loop after it finishes playing once.
  34794. */
  34795. loop: boolean;
  34796. /**
  34797. * Does the sound use a custom attenuation curve to simulate the falloff
  34798. * happening when the source gets further away from the camera.
  34799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34800. */
  34801. useCustomAttenuation: boolean;
  34802. /**
  34803. * The sound track id this sound belongs to.
  34804. */
  34805. soundTrackId: number;
  34806. /**
  34807. * Is this sound currently played.
  34808. */
  34809. isPlaying: boolean;
  34810. /**
  34811. * Is this sound currently paused.
  34812. */
  34813. isPaused: boolean;
  34814. /**
  34815. * Does this sound enables spatial sound.
  34816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34817. */
  34818. spatialSound: boolean;
  34819. /**
  34820. * Define the reference distance the sound should be heard perfectly.
  34821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34822. */
  34823. refDistance: number;
  34824. /**
  34825. * Define the roll off factor of spatial sounds.
  34826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34827. */
  34828. rolloffFactor: number;
  34829. /**
  34830. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34832. */
  34833. maxDistance: number;
  34834. /**
  34835. * Define the distance attenuation model the sound will follow.
  34836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34837. */
  34838. distanceModel: string;
  34839. /**
  34840. * @hidden
  34841. * Back Compat
  34842. **/
  34843. onended: () => any;
  34844. /**
  34845. * Observable event when the current playing sound finishes.
  34846. */
  34847. onEndedObservable: Observable<Sound>;
  34848. private _panningModel;
  34849. private _playbackRate;
  34850. private _streaming;
  34851. private _startTime;
  34852. private _startOffset;
  34853. private _position;
  34854. /** @hidden */
  34855. _positionInEmitterSpace: boolean;
  34856. private _localDirection;
  34857. private _volume;
  34858. private _isReadyToPlay;
  34859. private _isDirectional;
  34860. private _readyToPlayCallback;
  34861. private _audioBuffer;
  34862. private _soundSource;
  34863. private _streamingSource;
  34864. private _soundPanner;
  34865. private _soundGain;
  34866. private _inputAudioNode;
  34867. private _outputAudioNode;
  34868. private _coneInnerAngle;
  34869. private _coneOuterAngle;
  34870. private _coneOuterGain;
  34871. private _scene;
  34872. private _connectedTransformNode;
  34873. private _customAttenuationFunction;
  34874. private _registerFunc;
  34875. private _isOutputConnected;
  34876. private _htmlAudioElement;
  34877. private _urlType;
  34878. private _length?;
  34879. private _offset?;
  34880. /** @hidden */
  34881. static _SceneComponentInitialization: (scene: Scene) => void;
  34882. /**
  34883. * Create a sound and attach it to a scene
  34884. * @param name Name of your sound
  34885. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34886. * @param scene defines the scene the sound belongs to
  34887. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34888. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34889. */
  34890. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34891. /**
  34892. * Release the sound and its associated resources
  34893. */
  34894. dispose(): void;
  34895. /**
  34896. * Gets if the sounds is ready to be played or not.
  34897. * @returns true if ready, otherwise false
  34898. */
  34899. isReady(): boolean;
  34900. private _soundLoaded;
  34901. /**
  34902. * Sets the data of the sound from an audiobuffer
  34903. * @param audioBuffer The audioBuffer containing the data
  34904. */
  34905. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34906. /**
  34907. * Updates the current sounds options such as maxdistance, loop...
  34908. * @param options A JSON object containing values named as the object properties
  34909. */
  34910. updateOptions(options: ISoundOptions): void;
  34911. private _createSpatialParameters;
  34912. private _updateSpatialParameters;
  34913. /**
  34914. * Switch the panning model to HRTF:
  34915. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34917. */
  34918. switchPanningModelToHRTF(): void;
  34919. /**
  34920. * Switch the panning model to Equal Power:
  34921. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34923. */
  34924. switchPanningModelToEqualPower(): void;
  34925. private _switchPanningModel;
  34926. /**
  34927. * Connect this sound to a sound track audio node like gain...
  34928. * @param soundTrackAudioNode the sound track audio node to connect to
  34929. */
  34930. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34931. /**
  34932. * Transform this sound into a directional source
  34933. * @param coneInnerAngle Size of the inner cone in degree
  34934. * @param coneOuterAngle Size of the outer cone in degree
  34935. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34936. */
  34937. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34938. /**
  34939. * Gets or sets the inner angle for the directional cone.
  34940. */
  34941. /**
  34942. * Gets or sets the inner angle for the directional cone.
  34943. */
  34944. directionalConeInnerAngle: number;
  34945. /**
  34946. * Gets or sets the outer angle for the directional cone.
  34947. */
  34948. /**
  34949. * Gets or sets the outer angle for the directional cone.
  34950. */
  34951. directionalConeOuterAngle: number;
  34952. /**
  34953. * Sets the position of the emitter if spatial sound is enabled
  34954. * @param newPosition Defines the new posisiton
  34955. */
  34956. setPosition(newPosition: Vector3): void;
  34957. /**
  34958. * Sets the local direction of the emitter if spatial sound is enabled
  34959. * @param newLocalDirection Defines the new local direction
  34960. */
  34961. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34962. private _updateDirection;
  34963. /** @hidden */
  34964. updateDistanceFromListener(): void;
  34965. /**
  34966. * Sets a new custom attenuation function for the sound.
  34967. * @param callback Defines the function used for the attenuation
  34968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34969. */
  34970. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34971. /**
  34972. * Play the sound
  34973. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34974. * @param offset (optional) Start the sound at a specific time in seconds
  34975. * @param length (optional) Sound duration (in seconds)
  34976. */
  34977. play(time?: number, offset?: number, length?: number): void;
  34978. private _onended;
  34979. /**
  34980. * Stop the sound
  34981. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34982. */
  34983. stop(time?: number): void;
  34984. /**
  34985. * Put the sound in pause
  34986. */
  34987. pause(): void;
  34988. /**
  34989. * Sets a dedicated volume for this sounds
  34990. * @param newVolume Define the new volume of the sound
  34991. * @param time Define time for gradual change to new volume
  34992. */
  34993. setVolume(newVolume: number, time?: number): void;
  34994. /**
  34995. * Set the sound play back rate
  34996. * @param newPlaybackRate Define the playback rate the sound should be played at
  34997. */
  34998. setPlaybackRate(newPlaybackRate: number): void;
  34999. /**
  35000. * Gets the volume of the sound.
  35001. * @returns the volume of the sound
  35002. */
  35003. getVolume(): number;
  35004. /**
  35005. * Attach the sound to a dedicated mesh
  35006. * @param transformNode The transform node to connect the sound with
  35007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35008. */
  35009. attachToMesh(transformNode: TransformNode): void;
  35010. /**
  35011. * Detach the sound from the previously attached mesh
  35012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35013. */
  35014. detachFromMesh(): void;
  35015. private _onRegisterAfterWorldMatrixUpdate;
  35016. /**
  35017. * Clone the current sound in the scene.
  35018. * @returns the new sound clone
  35019. */
  35020. clone(): Nullable<Sound>;
  35021. /**
  35022. * Gets the current underlying audio buffer containing the data
  35023. * @returns the audio buffer
  35024. */
  35025. getAudioBuffer(): Nullable<AudioBuffer>;
  35026. /**
  35027. * Serializes the Sound in a JSON representation
  35028. * @returns the JSON representation of the sound
  35029. */
  35030. serialize(): any;
  35031. /**
  35032. * Parse a JSON representation of a sound to innstantiate in a given scene
  35033. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35034. * @param scene Define the scene the new parsed sound should be created in
  35035. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35036. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35037. * @returns the newly parsed sound
  35038. */
  35039. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35040. }
  35041. }
  35042. declare module BABYLON {
  35043. /**
  35044. * This defines an action helpful to play a defined sound on a triggered action.
  35045. */
  35046. export class PlaySoundAction extends Action {
  35047. private _sound;
  35048. /**
  35049. * Instantiate the action
  35050. * @param triggerOptions defines the trigger options
  35051. * @param sound defines the sound to play
  35052. * @param condition defines the trigger related conditions
  35053. */
  35054. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35055. /** @hidden */
  35056. _prepare(): void;
  35057. /**
  35058. * Execute the action and play the sound.
  35059. */
  35060. execute(): void;
  35061. /**
  35062. * Serializes the actions and its related information.
  35063. * @param parent defines the object to serialize in
  35064. * @returns the serialized object
  35065. */
  35066. serialize(parent: any): any;
  35067. }
  35068. /**
  35069. * This defines an action helpful to stop a defined sound on a triggered action.
  35070. */
  35071. export class StopSoundAction extends Action {
  35072. private _sound;
  35073. /**
  35074. * Instantiate the action
  35075. * @param triggerOptions defines the trigger options
  35076. * @param sound defines the sound to stop
  35077. * @param condition defines the trigger related conditions
  35078. */
  35079. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35080. /** @hidden */
  35081. _prepare(): void;
  35082. /**
  35083. * Execute the action and stop the sound.
  35084. */
  35085. execute(): void;
  35086. /**
  35087. * Serializes the actions and its related information.
  35088. * @param parent defines the object to serialize in
  35089. * @returns the serialized object
  35090. */
  35091. serialize(parent: any): any;
  35092. }
  35093. }
  35094. declare module BABYLON {
  35095. /**
  35096. * This defines an action responsible to change the value of a property
  35097. * by interpolating between its current value and the newly set one once triggered.
  35098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35099. */
  35100. export class InterpolateValueAction extends Action {
  35101. /**
  35102. * Defines the path of the property where the value should be interpolated
  35103. */
  35104. propertyPath: string;
  35105. /**
  35106. * Defines the target value at the end of the interpolation.
  35107. */
  35108. value: any;
  35109. /**
  35110. * Defines the time it will take for the property to interpolate to the value.
  35111. */
  35112. duration: number;
  35113. /**
  35114. * Defines if the other scene animations should be stopped when the action has been triggered
  35115. */
  35116. stopOtherAnimations?: boolean;
  35117. /**
  35118. * Defines a callback raised once the interpolation animation has been done.
  35119. */
  35120. onInterpolationDone?: () => void;
  35121. /**
  35122. * Observable triggered once the interpolation animation has been done.
  35123. */
  35124. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35125. private _target;
  35126. private _effectiveTarget;
  35127. private _property;
  35128. /**
  35129. * Instantiate the action
  35130. * @param triggerOptions defines the trigger options
  35131. * @param target defines the object containing the value to interpolate
  35132. * @param propertyPath defines the path to the property in the target object
  35133. * @param value defines the target value at the end of the interpolation
  35134. * @param duration deines the time it will take for the property to interpolate to the value.
  35135. * @param condition defines the trigger related conditions
  35136. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35137. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35138. */
  35139. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35140. /** @hidden */
  35141. _prepare(): void;
  35142. /**
  35143. * Execute the action starts the value interpolation.
  35144. */
  35145. execute(): void;
  35146. /**
  35147. * Serializes the actions and its related information.
  35148. * @param parent defines the object to serialize in
  35149. * @returns the serialized object
  35150. */
  35151. serialize(parent: any): any;
  35152. }
  35153. }
  35154. declare module BABYLON {
  35155. /**
  35156. * Options allowed during the creation of a sound track.
  35157. */
  35158. export interface ISoundTrackOptions {
  35159. /**
  35160. * The volume the sound track should take during creation
  35161. */
  35162. volume?: number;
  35163. /**
  35164. * Define if the sound track is the main sound track of the scene
  35165. */
  35166. mainTrack?: boolean;
  35167. }
  35168. /**
  35169. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35170. * It will be also used in a future release to apply effects on a specific track.
  35171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35172. */
  35173. export class SoundTrack {
  35174. /**
  35175. * The unique identifier of the sound track in the scene.
  35176. */
  35177. id: number;
  35178. /**
  35179. * The list of sounds included in the sound track.
  35180. */
  35181. soundCollection: Array<Sound>;
  35182. private _outputAudioNode;
  35183. private _scene;
  35184. private _isMainTrack;
  35185. private _connectedAnalyser;
  35186. private _options;
  35187. private _isInitialized;
  35188. /**
  35189. * Creates a new sound track.
  35190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35191. * @param scene Define the scene the sound track belongs to
  35192. * @param options
  35193. */
  35194. constructor(scene: Scene, options?: ISoundTrackOptions);
  35195. private _initializeSoundTrackAudioGraph;
  35196. /**
  35197. * Release the sound track and its associated resources
  35198. */
  35199. dispose(): void;
  35200. /**
  35201. * Adds a sound to this sound track
  35202. * @param sound define the cound to add
  35203. * @ignoreNaming
  35204. */
  35205. AddSound(sound: Sound): void;
  35206. /**
  35207. * Removes a sound to this sound track
  35208. * @param sound define the cound to remove
  35209. * @ignoreNaming
  35210. */
  35211. RemoveSound(sound: Sound): void;
  35212. /**
  35213. * Set a global volume for the full sound track.
  35214. * @param newVolume Define the new volume of the sound track
  35215. */
  35216. setVolume(newVolume: number): void;
  35217. /**
  35218. * Switch the panning model to HRTF:
  35219. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35221. */
  35222. switchPanningModelToHRTF(): void;
  35223. /**
  35224. * Switch the panning model to Equal Power:
  35225. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35227. */
  35228. switchPanningModelToEqualPower(): void;
  35229. /**
  35230. * Connect the sound track to an audio analyser allowing some amazing
  35231. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35233. * @param analyser The analyser to connect to the engine
  35234. */
  35235. connectToAnalyser(analyser: Analyser): void;
  35236. }
  35237. }
  35238. declare module BABYLON {
  35239. interface AbstractScene {
  35240. /**
  35241. * The list of sounds used in the scene.
  35242. */
  35243. sounds: Nullable<Array<Sound>>;
  35244. }
  35245. interface Scene {
  35246. /**
  35247. * @hidden
  35248. * Backing field
  35249. */
  35250. _mainSoundTrack: SoundTrack;
  35251. /**
  35252. * The main sound track played by the scene.
  35253. * It cotains your primary collection of sounds.
  35254. */
  35255. mainSoundTrack: SoundTrack;
  35256. /**
  35257. * The list of sound tracks added to the scene
  35258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35259. */
  35260. soundTracks: Nullable<Array<SoundTrack>>;
  35261. /**
  35262. * Gets a sound using a given name
  35263. * @param name defines the name to search for
  35264. * @return the found sound or null if not found at all.
  35265. */
  35266. getSoundByName(name: string): Nullable<Sound>;
  35267. /**
  35268. * Gets or sets if audio support is enabled
  35269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35270. */
  35271. audioEnabled: boolean;
  35272. /**
  35273. * Gets or sets if audio will be output to headphones
  35274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35275. */
  35276. headphone: boolean;
  35277. /**
  35278. * Gets or sets custom audio listener position provider
  35279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35280. */
  35281. audioListenerPositionProvider: Nullable<() => Vector3>;
  35282. }
  35283. /**
  35284. * Defines the sound scene component responsible to manage any sounds
  35285. * in a given scene.
  35286. */
  35287. export class AudioSceneComponent implements ISceneSerializableComponent {
  35288. /**
  35289. * The component name helpfull to identify the component in the list of scene components.
  35290. */
  35291. readonly name: string;
  35292. /**
  35293. * The scene the component belongs to.
  35294. */
  35295. scene: Scene;
  35296. private _audioEnabled;
  35297. /**
  35298. * Gets whether audio is enabled or not.
  35299. * Please use related enable/disable method to switch state.
  35300. */
  35301. readonly audioEnabled: boolean;
  35302. private _headphone;
  35303. /**
  35304. * Gets whether audio is outputing to headphone or not.
  35305. * Please use the according Switch methods to change output.
  35306. */
  35307. readonly headphone: boolean;
  35308. private _audioListenerPositionProvider;
  35309. /**
  35310. * Gets the current audio listener position provider
  35311. */
  35312. /**
  35313. * Sets a custom listener position for all sounds in the scene
  35314. * By default, this is the position of the first active camera
  35315. */
  35316. audioListenerPositionProvider: Nullable<() => Vector3>;
  35317. /**
  35318. * Creates a new instance of the component for the given scene
  35319. * @param scene Defines the scene to register the component in
  35320. */
  35321. constructor(scene: Scene);
  35322. /**
  35323. * Registers the component in a given scene
  35324. */
  35325. register(): void;
  35326. /**
  35327. * Rebuilds the elements related to this component in case of
  35328. * context lost for instance.
  35329. */
  35330. rebuild(): void;
  35331. /**
  35332. * Serializes the component data to the specified json object
  35333. * @param serializationObject The object to serialize to
  35334. */
  35335. serialize(serializationObject: any): void;
  35336. /**
  35337. * Adds all the elements from the container to the scene
  35338. * @param container the container holding the elements
  35339. */
  35340. addFromContainer(container: AbstractScene): void;
  35341. /**
  35342. * Removes all the elements in the container from the scene
  35343. * @param container contains the elements to remove
  35344. * @param dispose if the removed element should be disposed (default: false)
  35345. */
  35346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35347. /**
  35348. * Disposes the component and the associated ressources.
  35349. */
  35350. dispose(): void;
  35351. /**
  35352. * Disables audio in the associated scene.
  35353. */
  35354. disableAudio(): void;
  35355. /**
  35356. * Enables audio in the associated scene.
  35357. */
  35358. enableAudio(): void;
  35359. /**
  35360. * Switch audio to headphone output.
  35361. */
  35362. switchAudioModeForHeadphones(): void;
  35363. /**
  35364. * Switch audio to normal speakers.
  35365. */
  35366. switchAudioModeForNormalSpeakers(): void;
  35367. private _afterRender;
  35368. }
  35369. }
  35370. declare module BABYLON {
  35371. /**
  35372. * Wraps one or more Sound objects and selects one with random weight for playback.
  35373. */
  35374. export class WeightedSound {
  35375. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35376. loop: boolean;
  35377. private _coneInnerAngle;
  35378. private _coneOuterAngle;
  35379. private _volume;
  35380. /** A Sound is currently playing. */
  35381. isPlaying: boolean;
  35382. /** A Sound is currently paused. */
  35383. isPaused: boolean;
  35384. private _sounds;
  35385. private _weights;
  35386. private _currentIndex?;
  35387. /**
  35388. * Creates a new WeightedSound from the list of sounds given.
  35389. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35390. * @param sounds Array of Sounds that will be selected from.
  35391. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35392. */
  35393. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35394. /**
  35395. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35396. */
  35397. /**
  35398. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35399. */
  35400. directionalConeInnerAngle: number;
  35401. /**
  35402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35404. */
  35405. /**
  35406. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35407. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35408. */
  35409. directionalConeOuterAngle: number;
  35410. /**
  35411. * Playback volume.
  35412. */
  35413. /**
  35414. * Playback volume.
  35415. */
  35416. volume: number;
  35417. private _onended;
  35418. /**
  35419. * Suspend playback
  35420. */
  35421. pause(): void;
  35422. /**
  35423. * Stop playback
  35424. */
  35425. stop(): void;
  35426. /**
  35427. * Start playback.
  35428. * @param startOffset Position the clip head at a specific time in seconds.
  35429. */
  35430. play(startOffset?: number): void;
  35431. }
  35432. }
  35433. declare module BABYLON {
  35434. /**
  35435. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35437. */
  35438. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35439. /**
  35440. * Gets the name of the behavior.
  35441. */
  35442. readonly name: string;
  35443. /**
  35444. * The easing function used by animations
  35445. */
  35446. static EasingFunction: BackEase;
  35447. /**
  35448. * The easing mode used by animations
  35449. */
  35450. static EasingMode: number;
  35451. /**
  35452. * The duration of the animation, in milliseconds
  35453. */
  35454. transitionDuration: number;
  35455. /**
  35456. * Length of the distance animated by the transition when lower radius is reached
  35457. */
  35458. lowerRadiusTransitionRange: number;
  35459. /**
  35460. * Length of the distance animated by the transition when upper radius is reached
  35461. */
  35462. upperRadiusTransitionRange: number;
  35463. private _autoTransitionRange;
  35464. /**
  35465. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35466. */
  35467. /**
  35468. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35469. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35470. */
  35471. autoTransitionRange: boolean;
  35472. private _attachedCamera;
  35473. private _onAfterCheckInputsObserver;
  35474. private _onMeshTargetChangedObserver;
  35475. /**
  35476. * Initializes the behavior.
  35477. */
  35478. init(): void;
  35479. /**
  35480. * Attaches the behavior to its arc rotate camera.
  35481. * @param camera Defines the camera to attach the behavior to
  35482. */
  35483. attach(camera: ArcRotateCamera): void;
  35484. /**
  35485. * Detaches the behavior from its current arc rotate camera.
  35486. */
  35487. detach(): void;
  35488. private _radiusIsAnimating;
  35489. private _radiusBounceTransition;
  35490. private _animatables;
  35491. private _cachedWheelPrecision;
  35492. /**
  35493. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35494. * @param radiusLimit The limit to check against.
  35495. * @return Bool to indicate if at limit.
  35496. */
  35497. private _isRadiusAtLimit;
  35498. /**
  35499. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35500. * @param radiusDelta The delta by which to animate to. Can be negative.
  35501. */
  35502. private _applyBoundRadiusAnimation;
  35503. /**
  35504. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35505. */
  35506. protected _clearAnimationLocks(): void;
  35507. /**
  35508. * Stops and removes all animations that have been applied to the camera
  35509. */
  35510. stopAllAnimations(): void;
  35511. }
  35512. }
  35513. declare module BABYLON {
  35514. /**
  35515. * 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.
  35516. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35517. */
  35518. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35519. /**
  35520. * Gets the name of the behavior.
  35521. */
  35522. readonly name: string;
  35523. private _mode;
  35524. private _radiusScale;
  35525. private _positionScale;
  35526. private _defaultElevation;
  35527. private _elevationReturnTime;
  35528. private _elevationReturnWaitTime;
  35529. private _zoomStopsAnimation;
  35530. private _framingTime;
  35531. /**
  35532. * The easing function used by animations
  35533. */
  35534. static EasingFunction: ExponentialEase;
  35535. /**
  35536. * The easing mode used by animations
  35537. */
  35538. static EasingMode: number;
  35539. /**
  35540. * Sets the current mode used by the behavior
  35541. */
  35542. /**
  35543. * Gets current mode used by the behavior.
  35544. */
  35545. mode: number;
  35546. /**
  35547. * Sets the scale applied to the radius (1 by default)
  35548. */
  35549. /**
  35550. * Gets the scale applied to the radius
  35551. */
  35552. radiusScale: number;
  35553. /**
  35554. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35555. */
  35556. /**
  35557. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35558. */
  35559. positionScale: number;
  35560. /**
  35561. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35562. * behaviour is triggered, in radians.
  35563. */
  35564. /**
  35565. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35566. * behaviour is triggered, in radians.
  35567. */
  35568. defaultElevation: number;
  35569. /**
  35570. * Sets the time (in milliseconds) taken to return to the default beta position.
  35571. * Negative value indicates camera should not return to default.
  35572. */
  35573. /**
  35574. * Gets the time (in milliseconds) taken to return to the default beta position.
  35575. * Negative value indicates camera should not return to default.
  35576. */
  35577. elevationReturnTime: number;
  35578. /**
  35579. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35580. */
  35581. /**
  35582. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35583. */
  35584. elevationReturnWaitTime: number;
  35585. /**
  35586. * Sets the flag that indicates if user zooming should stop animation.
  35587. */
  35588. /**
  35589. * Gets the flag that indicates if user zooming should stop animation.
  35590. */
  35591. zoomStopsAnimation: boolean;
  35592. /**
  35593. * Sets the transition time when framing the mesh, in milliseconds
  35594. */
  35595. /**
  35596. * Gets the transition time when framing the mesh, in milliseconds
  35597. */
  35598. framingTime: number;
  35599. /**
  35600. * Define if the behavior should automatically change the configured
  35601. * camera limits and sensibilities.
  35602. */
  35603. autoCorrectCameraLimitsAndSensibility: boolean;
  35604. private _onPrePointerObservableObserver;
  35605. private _onAfterCheckInputsObserver;
  35606. private _onMeshTargetChangedObserver;
  35607. private _attachedCamera;
  35608. private _isPointerDown;
  35609. private _lastInteractionTime;
  35610. /**
  35611. * Initializes the behavior.
  35612. */
  35613. init(): void;
  35614. /**
  35615. * Attaches the behavior to its arc rotate camera.
  35616. * @param camera Defines the camera to attach the behavior to
  35617. */
  35618. attach(camera: ArcRotateCamera): void;
  35619. /**
  35620. * Detaches the behavior from its current arc rotate camera.
  35621. */
  35622. detach(): void;
  35623. private _animatables;
  35624. private _betaIsAnimating;
  35625. private _betaTransition;
  35626. private _radiusTransition;
  35627. private _vectorTransition;
  35628. /**
  35629. * Targets the given mesh and updates zoom level accordingly.
  35630. * @param mesh The mesh to target.
  35631. * @param radius Optional. If a cached radius position already exists, overrides default.
  35632. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35633. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35634. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35635. */
  35636. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35637. /**
  35638. * Targets the given mesh with its children and updates zoom level accordingly.
  35639. * @param mesh The mesh to target.
  35640. * @param radius Optional. If a cached radius position already exists, overrides default.
  35641. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35642. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35643. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35644. */
  35645. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35646. /**
  35647. * Targets the given meshes with their children and updates zoom level accordingly.
  35648. * @param meshes The mesh to target.
  35649. * @param radius Optional. If a cached radius position already exists, overrides default.
  35650. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35651. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35652. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35653. */
  35654. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35655. /**
  35656. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35657. * @param minimumWorld Determines the smaller position of the bounding box extend
  35658. * @param maximumWorld Determines the bigger position of the bounding box extend
  35659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35661. */
  35662. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35663. /**
  35664. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35665. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35666. * frustum width.
  35667. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35668. * to fully enclose the mesh in the viewing frustum.
  35669. */
  35670. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35671. /**
  35672. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35673. * is automatically returned to its default position (expected to be above ground plane).
  35674. */
  35675. private _maintainCameraAboveGround;
  35676. /**
  35677. * Returns the frustum slope based on the canvas ratio and camera FOV
  35678. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35679. */
  35680. private _getFrustumSlope;
  35681. /**
  35682. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35683. */
  35684. private _clearAnimationLocks;
  35685. /**
  35686. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35687. */
  35688. private _applyUserInteraction;
  35689. /**
  35690. * Stops and removes all animations that have been applied to the camera
  35691. */
  35692. stopAllAnimations(): void;
  35693. /**
  35694. * Gets a value indicating if the user is moving the camera
  35695. */
  35696. readonly isUserIsMoving: boolean;
  35697. /**
  35698. * The camera can move all the way towards the mesh.
  35699. */
  35700. static IgnoreBoundsSizeMode: number;
  35701. /**
  35702. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35703. */
  35704. static FitFrustumSidesMode: number;
  35705. }
  35706. }
  35707. declare module BABYLON {
  35708. /**
  35709. * Base class for Camera Pointer Inputs.
  35710. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35711. * for example usage.
  35712. */
  35713. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35714. /**
  35715. * Defines the camera the input is attached to.
  35716. */
  35717. abstract camera: Camera;
  35718. /**
  35719. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35720. */
  35721. protected _altKey: boolean;
  35722. protected _ctrlKey: boolean;
  35723. protected _metaKey: boolean;
  35724. protected _shiftKey: boolean;
  35725. /**
  35726. * Which mouse buttons were pressed at time of last mouse event.
  35727. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35728. */
  35729. protected _buttonsPressed: number;
  35730. /**
  35731. * Defines the buttons associated with the input to handle camera move.
  35732. */
  35733. buttons: number[];
  35734. /**
  35735. * Attach the input controls to a specific dom element to get the input from.
  35736. * @param element Defines the element the controls should be listened from
  35737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35738. */
  35739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35740. /**
  35741. * Detach the current controls from the specified dom element.
  35742. * @param element Defines the element to stop listening the inputs from
  35743. */
  35744. detachControl(element: Nullable<HTMLElement>): void;
  35745. /**
  35746. * Gets the class name of the current input.
  35747. * @returns the class name
  35748. */
  35749. getClassName(): string;
  35750. /**
  35751. * Get the friendly name associated with the input class.
  35752. * @returns the input friendly name
  35753. */
  35754. getSimpleName(): string;
  35755. /**
  35756. * Called on pointer POINTERDOUBLETAP event.
  35757. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35758. */
  35759. protected onDoubleTap(type: string): void;
  35760. /**
  35761. * Called on pointer POINTERMOVE event if only a single touch is active.
  35762. * Override this method to provide functionality.
  35763. */
  35764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35765. /**
  35766. * Called on pointer POINTERMOVE event if multiple touches are active.
  35767. * Override this method to provide functionality.
  35768. */
  35769. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35770. /**
  35771. * Called on JS contextmenu event.
  35772. * Override this method to provide functionality.
  35773. */
  35774. protected onContextMenu(evt: PointerEvent): void;
  35775. /**
  35776. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35777. * press.
  35778. * Override this method to provide functionality.
  35779. */
  35780. protected onButtonDown(evt: PointerEvent): void;
  35781. /**
  35782. * Called each time a new POINTERUP event occurs. Ie, for each button
  35783. * release.
  35784. * Override this method to provide functionality.
  35785. */
  35786. protected onButtonUp(evt: PointerEvent): void;
  35787. /**
  35788. * Called when window becomes inactive.
  35789. * Override this method to provide functionality.
  35790. */
  35791. protected onLostFocus(): void;
  35792. private _pointerInput;
  35793. private _observer;
  35794. private _onLostFocus;
  35795. private pointA;
  35796. private pointB;
  35797. }
  35798. }
  35799. declare module BABYLON {
  35800. /**
  35801. * Manage the pointers inputs to control an arc rotate camera.
  35802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35803. */
  35804. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35805. /**
  35806. * Defines the camera the input is attached to.
  35807. */
  35808. camera: ArcRotateCamera;
  35809. /**
  35810. * Gets the class name of the current input.
  35811. * @returns the class name
  35812. */
  35813. getClassName(): string;
  35814. /**
  35815. * Defines the buttons associated with the input to handle camera move.
  35816. */
  35817. buttons: number[];
  35818. /**
  35819. * Defines the pointer angular sensibility along the X axis or how fast is
  35820. * the camera rotating.
  35821. */
  35822. angularSensibilityX: number;
  35823. /**
  35824. * Defines the pointer angular sensibility along the Y axis or how fast is
  35825. * the camera rotating.
  35826. */
  35827. angularSensibilityY: number;
  35828. /**
  35829. * Defines the pointer pinch precision or how fast is the camera zooming.
  35830. */
  35831. pinchPrecision: number;
  35832. /**
  35833. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35834. * from 0.
  35835. * It defines the percentage of current camera.radius to use as delta when
  35836. * pinch zoom is used.
  35837. */
  35838. pinchDeltaPercentage: number;
  35839. /**
  35840. * Defines the pointer panning sensibility or how fast is the camera moving.
  35841. */
  35842. panningSensibility: number;
  35843. /**
  35844. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35845. */
  35846. multiTouchPanning: boolean;
  35847. /**
  35848. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35849. * zoom (pinch) through multitouch.
  35850. */
  35851. multiTouchPanAndZoom: boolean;
  35852. /**
  35853. * Revers pinch action direction.
  35854. */
  35855. pinchInwards: boolean;
  35856. private _isPanClick;
  35857. private _twoFingerActivityCount;
  35858. private _isPinching;
  35859. /**
  35860. * Called on pointer POINTERMOVE event if only a single touch is active.
  35861. */
  35862. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35863. /**
  35864. * Called on pointer POINTERDOUBLETAP event.
  35865. */
  35866. protected onDoubleTap(type: string): void;
  35867. /**
  35868. * Called on pointer POINTERMOVE event if multiple touches are active.
  35869. */
  35870. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35871. /**
  35872. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35873. * press.
  35874. */
  35875. protected onButtonDown(evt: PointerEvent): void;
  35876. /**
  35877. * Called each time a new POINTERUP event occurs. Ie, for each button
  35878. * release.
  35879. */
  35880. protected onButtonUp(evt: PointerEvent): void;
  35881. /**
  35882. * Called when window becomes inactive.
  35883. */
  35884. protected onLostFocus(): void;
  35885. }
  35886. }
  35887. declare module BABYLON {
  35888. /**
  35889. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35891. */
  35892. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35893. /**
  35894. * Defines the camera the input is attached to.
  35895. */
  35896. camera: ArcRotateCamera;
  35897. /**
  35898. * Defines the list of key codes associated with the up action (increase alpha)
  35899. */
  35900. keysUp: number[];
  35901. /**
  35902. * Defines the list of key codes associated with the down action (decrease alpha)
  35903. */
  35904. keysDown: number[];
  35905. /**
  35906. * Defines the list of key codes associated with the left action (increase beta)
  35907. */
  35908. keysLeft: number[];
  35909. /**
  35910. * Defines the list of key codes associated with the right action (decrease beta)
  35911. */
  35912. keysRight: number[];
  35913. /**
  35914. * Defines the list of key codes associated with the reset action.
  35915. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35916. */
  35917. keysReset: number[];
  35918. /**
  35919. * Defines the panning sensibility of the inputs.
  35920. * (How fast is the camera paning)
  35921. */
  35922. panningSensibility: number;
  35923. /**
  35924. * Defines the zooming sensibility of the inputs.
  35925. * (How fast is the camera zooming)
  35926. */
  35927. zoomingSensibility: number;
  35928. /**
  35929. * Defines wether maintaining the alt key down switch the movement mode from
  35930. * orientation to zoom.
  35931. */
  35932. useAltToZoom: boolean;
  35933. /**
  35934. * Rotation speed of the camera
  35935. */
  35936. angularSpeed: number;
  35937. private _keys;
  35938. private _ctrlPressed;
  35939. private _altPressed;
  35940. private _onCanvasBlurObserver;
  35941. private _onKeyboardObserver;
  35942. private _engine;
  35943. private _scene;
  35944. /**
  35945. * Attach the input controls to a specific dom element to get the input from.
  35946. * @param element Defines the element the controls should be listened from
  35947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35948. */
  35949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35950. /**
  35951. * Detach the current controls from the specified dom element.
  35952. * @param element Defines the element to stop listening the inputs from
  35953. */
  35954. detachControl(element: Nullable<HTMLElement>): void;
  35955. /**
  35956. * Update the current camera state depending on the inputs that have been used this frame.
  35957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35958. */
  35959. checkInputs(): void;
  35960. /**
  35961. * Gets the class name of the current intput.
  35962. * @returns the class name
  35963. */
  35964. getClassName(): string;
  35965. /**
  35966. * Get the friendly name associated with the input class.
  35967. * @returns the input friendly name
  35968. */
  35969. getSimpleName(): string;
  35970. }
  35971. }
  35972. declare module BABYLON {
  35973. /**
  35974. * Manage the mouse wheel inputs to control an arc rotate camera.
  35975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35976. */
  35977. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35978. /**
  35979. * Defines the camera the input is attached to.
  35980. */
  35981. camera: ArcRotateCamera;
  35982. /**
  35983. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35984. */
  35985. wheelPrecision: number;
  35986. /**
  35987. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35988. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35989. */
  35990. wheelDeltaPercentage: number;
  35991. private _wheel;
  35992. private _observer;
  35993. private computeDeltaFromMouseWheelLegacyEvent;
  35994. /**
  35995. * Attach the input controls to a specific dom element to get the input from.
  35996. * @param element Defines the element the controls should be listened from
  35997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35998. */
  35999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36000. /**
  36001. * Detach the current controls from the specified dom element.
  36002. * @param element Defines the element to stop listening the inputs from
  36003. */
  36004. detachControl(element: Nullable<HTMLElement>): void;
  36005. /**
  36006. * Gets the class name of the current intput.
  36007. * @returns the class name
  36008. */
  36009. getClassName(): string;
  36010. /**
  36011. * Get the friendly name associated with the input class.
  36012. * @returns the input friendly name
  36013. */
  36014. getSimpleName(): string;
  36015. }
  36016. }
  36017. declare module BABYLON {
  36018. /**
  36019. * Default Inputs manager for the ArcRotateCamera.
  36020. * It groups all the default supported inputs for ease of use.
  36021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36022. */
  36023. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36024. /**
  36025. * Instantiates a new ArcRotateCameraInputsManager.
  36026. * @param camera Defines the camera the inputs belong to
  36027. */
  36028. constructor(camera: ArcRotateCamera);
  36029. /**
  36030. * Add mouse wheel input support to the input manager.
  36031. * @returns the current input manager
  36032. */
  36033. addMouseWheel(): ArcRotateCameraInputsManager;
  36034. /**
  36035. * Add pointers input support to the input manager.
  36036. * @returns the current input manager
  36037. */
  36038. addPointers(): ArcRotateCameraInputsManager;
  36039. /**
  36040. * Add keyboard input support to the input manager.
  36041. * @returns the current input manager
  36042. */
  36043. addKeyboard(): ArcRotateCameraInputsManager;
  36044. }
  36045. }
  36046. declare module BABYLON {
  36047. /**
  36048. * This represents an orbital type of camera.
  36049. *
  36050. * 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.
  36051. * 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.
  36052. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36053. */
  36054. export class ArcRotateCamera extends TargetCamera {
  36055. /**
  36056. * Defines the rotation angle of the camera along the longitudinal axis.
  36057. */
  36058. alpha: number;
  36059. /**
  36060. * Defines the rotation angle of the camera along the latitudinal axis.
  36061. */
  36062. beta: number;
  36063. /**
  36064. * Defines the radius of the camera from it s target point.
  36065. */
  36066. radius: number;
  36067. protected _target: Vector3;
  36068. protected _targetHost: Nullable<AbstractMesh>;
  36069. /**
  36070. * Defines the target point of the camera.
  36071. * The camera looks towards it form the radius distance.
  36072. */
  36073. target: Vector3;
  36074. /**
  36075. * Define the current local position of the camera in the scene
  36076. */
  36077. position: Vector3;
  36078. protected _upVector: Vector3;
  36079. protected _upToYMatrix: Matrix;
  36080. protected _YToUpMatrix: Matrix;
  36081. /**
  36082. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36083. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36084. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36085. */
  36086. upVector: Vector3;
  36087. /**
  36088. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36089. */
  36090. setMatUp(): void;
  36091. /**
  36092. * Current inertia value on the longitudinal axis.
  36093. * The bigger this number the longer it will take for the camera to stop.
  36094. */
  36095. inertialAlphaOffset: number;
  36096. /**
  36097. * Current inertia value on the latitudinal axis.
  36098. * The bigger this number the longer it will take for the camera to stop.
  36099. */
  36100. inertialBetaOffset: number;
  36101. /**
  36102. * Current inertia value on the radius axis.
  36103. * The bigger this number the longer it will take for the camera to stop.
  36104. */
  36105. inertialRadiusOffset: number;
  36106. /**
  36107. * Minimum allowed angle on the longitudinal axis.
  36108. * This can help limiting how the Camera is able to move in the scene.
  36109. */
  36110. lowerAlphaLimit: Nullable<number>;
  36111. /**
  36112. * Maximum allowed angle on the longitudinal axis.
  36113. * This can help limiting how the Camera is able to move in the scene.
  36114. */
  36115. upperAlphaLimit: Nullable<number>;
  36116. /**
  36117. * Minimum allowed angle on the latitudinal axis.
  36118. * This can help limiting how the Camera is able to move in the scene.
  36119. */
  36120. lowerBetaLimit: number;
  36121. /**
  36122. * Maximum allowed angle on the latitudinal axis.
  36123. * This can help limiting how the Camera is able to move in the scene.
  36124. */
  36125. upperBetaLimit: number;
  36126. /**
  36127. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36128. * This can help limiting how the Camera is able to move in the scene.
  36129. */
  36130. lowerRadiusLimit: Nullable<number>;
  36131. /**
  36132. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36133. * This can help limiting how the Camera is able to move in the scene.
  36134. */
  36135. upperRadiusLimit: Nullable<number>;
  36136. /**
  36137. * Defines the current inertia value used during panning of the camera along the X axis.
  36138. */
  36139. inertialPanningX: number;
  36140. /**
  36141. * Defines the current inertia value used during panning of the camera along the Y axis.
  36142. */
  36143. inertialPanningY: number;
  36144. /**
  36145. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36146. * Basically if your fingers moves away from more than this distance you will be considered
  36147. * in pinch mode.
  36148. */
  36149. pinchToPanMaxDistance: number;
  36150. /**
  36151. * Defines the maximum distance the camera can pan.
  36152. * This could help keeping the cammera always in your scene.
  36153. */
  36154. panningDistanceLimit: Nullable<number>;
  36155. /**
  36156. * Defines the target of the camera before paning.
  36157. */
  36158. panningOriginTarget: Vector3;
  36159. /**
  36160. * Defines the value of the inertia used during panning.
  36161. * 0 would mean stop inertia and one would mean no decelleration at all.
  36162. */
  36163. panningInertia: number;
  36164. /**
  36165. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36166. */
  36167. angularSensibilityX: number;
  36168. /**
  36169. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36170. */
  36171. angularSensibilityY: number;
  36172. /**
  36173. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36174. */
  36175. pinchPrecision: number;
  36176. /**
  36177. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36178. * It will be used instead of pinchDeltaPrecision if different from 0.
  36179. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36180. */
  36181. pinchDeltaPercentage: number;
  36182. /**
  36183. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36184. */
  36185. panningSensibility: number;
  36186. /**
  36187. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36188. */
  36189. keysUp: number[];
  36190. /**
  36191. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36192. */
  36193. keysDown: number[];
  36194. /**
  36195. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36196. */
  36197. keysLeft: number[];
  36198. /**
  36199. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36200. */
  36201. keysRight: number[];
  36202. /**
  36203. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36204. */
  36205. wheelPrecision: number;
  36206. /**
  36207. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36208. * It will be used instead of pinchDeltaPrecision if different from 0.
  36209. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36210. */
  36211. wheelDeltaPercentage: number;
  36212. /**
  36213. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36214. */
  36215. zoomOnFactor: number;
  36216. /**
  36217. * Defines a screen offset for the camera position.
  36218. */
  36219. targetScreenOffset: Vector2;
  36220. /**
  36221. * Allows the camera to be completely reversed.
  36222. * If false the camera can not arrive upside down.
  36223. */
  36224. allowUpsideDown: boolean;
  36225. /**
  36226. * Define if double tap/click is used to restore the previously saved state of the camera.
  36227. */
  36228. useInputToRestoreState: boolean;
  36229. /** @hidden */
  36230. _viewMatrix: Matrix;
  36231. /** @hidden */
  36232. _useCtrlForPanning: boolean;
  36233. /** @hidden */
  36234. _panningMouseButton: number;
  36235. /**
  36236. * Defines the input associated to the camera.
  36237. */
  36238. inputs: ArcRotateCameraInputsManager;
  36239. /** @hidden */
  36240. _reset: () => void;
  36241. /**
  36242. * Defines the allowed panning axis.
  36243. */
  36244. panningAxis: Vector3;
  36245. protected _localDirection: Vector3;
  36246. protected _transformedDirection: Vector3;
  36247. private _bouncingBehavior;
  36248. /**
  36249. * Gets the bouncing behavior of the camera if it has been enabled.
  36250. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36251. */
  36252. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36253. /**
  36254. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36256. */
  36257. useBouncingBehavior: boolean;
  36258. private _framingBehavior;
  36259. /**
  36260. * Gets the framing behavior of the camera if it has been enabled.
  36261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36262. */
  36263. readonly framingBehavior: Nullable<FramingBehavior>;
  36264. /**
  36265. * Defines if the framing behavior of the camera is enabled on the camera.
  36266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36267. */
  36268. useFramingBehavior: boolean;
  36269. private _autoRotationBehavior;
  36270. /**
  36271. * Gets the auto rotation behavior of the camera if it has been enabled.
  36272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36273. */
  36274. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36275. /**
  36276. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36278. */
  36279. useAutoRotationBehavior: boolean;
  36280. /**
  36281. * Observable triggered when the mesh target has been changed on the camera.
  36282. */
  36283. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36284. /**
  36285. * Event raised when the camera is colliding with a mesh.
  36286. */
  36287. onCollide: (collidedMesh: AbstractMesh) => void;
  36288. /**
  36289. * Defines whether the camera should check collision with the objects oh the scene.
  36290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36291. */
  36292. checkCollisions: boolean;
  36293. /**
  36294. * Defines the collision radius of the camera.
  36295. * This simulates a sphere around the camera.
  36296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36297. */
  36298. collisionRadius: Vector3;
  36299. protected _collider: Collider;
  36300. protected _previousPosition: Vector3;
  36301. protected _collisionVelocity: Vector3;
  36302. protected _newPosition: Vector3;
  36303. protected _previousAlpha: number;
  36304. protected _previousBeta: number;
  36305. protected _previousRadius: number;
  36306. protected _collisionTriggered: boolean;
  36307. protected _targetBoundingCenter: Nullable<Vector3>;
  36308. private _computationVector;
  36309. /**
  36310. * Instantiates a new ArcRotateCamera in a given scene
  36311. * @param name Defines the name of the camera
  36312. * @param alpha Defines the camera rotation along the logitudinal axis
  36313. * @param beta Defines the camera rotation along the latitudinal axis
  36314. * @param radius Defines the camera distance from its target
  36315. * @param target Defines the camera target
  36316. * @param scene Defines the scene the camera belongs to
  36317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36318. */
  36319. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36320. /** @hidden */
  36321. _initCache(): void;
  36322. /** @hidden */
  36323. _updateCache(ignoreParentClass?: boolean): void;
  36324. protected _getTargetPosition(): Vector3;
  36325. private _storedAlpha;
  36326. private _storedBeta;
  36327. private _storedRadius;
  36328. private _storedTarget;
  36329. private _storedTargetScreenOffset;
  36330. /**
  36331. * Stores the current state of the camera (alpha, beta, radius and target)
  36332. * @returns the camera itself
  36333. */
  36334. storeState(): Camera;
  36335. /**
  36336. * @hidden
  36337. * Restored camera state. You must call storeState() first
  36338. */
  36339. _restoreStateValues(): boolean;
  36340. /** @hidden */
  36341. _isSynchronizedViewMatrix(): boolean;
  36342. /**
  36343. * Attached controls to the current camera.
  36344. * @param element Defines the element the controls should be listened from
  36345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36346. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36347. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36348. */
  36349. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36350. /**
  36351. * Detach the current controls from the camera.
  36352. * The camera will stop reacting to inputs.
  36353. * @param element Defines the element to stop listening the inputs from
  36354. */
  36355. detachControl(element: HTMLElement): void;
  36356. /** @hidden */
  36357. _checkInputs(): void;
  36358. protected _checkLimits(): void;
  36359. /**
  36360. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36361. */
  36362. rebuildAnglesAndRadius(): void;
  36363. /**
  36364. * Use a position to define the current camera related information like aplha, beta and radius
  36365. * @param position Defines the position to set the camera at
  36366. */
  36367. setPosition(position: Vector3): void;
  36368. /**
  36369. * Defines the target the camera should look at.
  36370. * This will automatically adapt alpha beta and radius to fit within the new target.
  36371. * @param target Defines the new target as a Vector or a mesh
  36372. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36373. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36374. */
  36375. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36376. /** @hidden */
  36377. _getViewMatrix(): Matrix;
  36378. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36379. /**
  36380. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36381. * @param meshes Defines the mesh to zoom on
  36382. * @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)
  36383. */
  36384. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36385. /**
  36386. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36387. * The target will be changed but the radius
  36388. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36389. * @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)
  36390. */
  36391. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36392. min: Vector3;
  36393. max: Vector3;
  36394. distance: number;
  36395. }, doNotUpdateMaxZ?: boolean): void;
  36396. /**
  36397. * @override
  36398. * Override Camera.createRigCamera
  36399. */
  36400. createRigCamera(name: string, cameraIndex: number): Camera;
  36401. /**
  36402. * @hidden
  36403. * @override
  36404. * Override Camera._updateRigCameras
  36405. */
  36406. _updateRigCameras(): void;
  36407. /**
  36408. * Destroy the camera and release the current resources hold by it.
  36409. */
  36410. dispose(): void;
  36411. /**
  36412. * Gets the current object class name.
  36413. * @return the class name
  36414. */
  36415. getClassName(): string;
  36416. }
  36417. }
  36418. declare module BABYLON {
  36419. /**
  36420. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36421. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36422. */
  36423. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36424. /**
  36425. * Gets the name of the behavior.
  36426. */
  36427. readonly name: string;
  36428. private _zoomStopsAnimation;
  36429. private _idleRotationSpeed;
  36430. private _idleRotationWaitTime;
  36431. private _idleRotationSpinupTime;
  36432. /**
  36433. * Sets the flag that indicates if user zooming should stop animation.
  36434. */
  36435. /**
  36436. * Gets the flag that indicates if user zooming should stop animation.
  36437. */
  36438. zoomStopsAnimation: boolean;
  36439. /**
  36440. * Sets the default speed at which the camera rotates around the model.
  36441. */
  36442. /**
  36443. * Gets the default speed at which the camera rotates around the model.
  36444. */
  36445. idleRotationSpeed: number;
  36446. /**
  36447. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36448. */
  36449. /**
  36450. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36451. */
  36452. idleRotationWaitTime: number;
  36453. /**
  36454. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36455. */
  36456. /**
  36457. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36458. */
  36459. idleRotationSpinupTime: number;
  36460. /**
  36461. * Gets a value indicating if the camera is currently rotating because of this behavior
  36462. */
  36463. readonly rotationInProgress: boolean;
  36464. private _onPrePointerObservableObserver;
  36465. private _onAfterCheckInputsObserver;
  36466. private _attachedCamera;
  36467. private _isPointerDown;
  36468. private _lastFrameTime;
  36469. private _lastInteractionTime;
  36470. private _cameraRotationSpeed;
  36471. /**
  36472. * Initializes the behavior.
  36473. */
  36474. init(): void;
  36475. /**
  36476. * Attaches the behavior to its arc rotate camera.
  36477. * @param camera Defines the camera to attach the behavior to
  36478. */
  36479. attach(camera: ArcRotateCamera): void;
  36480. /**
  36481. * Detaches the behavior from its current arc rotate camera.
  36482. */
  36483. detach(): void;
  36484. /**
  36485. * Returns true if user is scrolling.
  36486. * @return true if user is scrolling.
  36487. */
  36488. private _userIsZooming;
  36489. private _lastFrameRadius;
  36490. private _shouldAnimationStopForInteraction;
  36491. /**
  36492. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36493. */
  36494. private _applyUserInteraction;
  36495. private _userIsMoving;
  36496. }
  36497. }
  36498. declare module BABYLON {
  36499. /**
  36500. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36501. */
  36502. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36503. private ui;
  36504. /**
  36505. * The name of the behavior
  36506. */
  36507. name: string;
  36508. /**
  36509. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36510. */
  36511. distanceAwayFromFace: number;
  36512. /**
  36513. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36514. */
  36515. distanceAwayFromBottomOfFace: number;
  36516. private _faceVectors;
  36517. private _target;
  36518. private _scene;
  36519. private _onRenderObserver;
  36520. private _tmpMatrix;
  36521. private _tmpVector;
  36522. /**
  36523. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36524. * @param ui The transform node that should be attched to the mesh
  36525. */
  36526. constructor(ui: TransformNode);
  36527. /**
  36528. * Initializes the behavior
  36529. */
  36530. init(): void;
  36531. private _closestFace;
  36532. private _zeroVector;
  36533. private _lookAtTmpMatrix;
  36534. private _lookAtToRef;
  36535. /**
  36536. * Attaches the AttachToBoxBehavior to the passed in mesh
  36537. * @param target The mesh that the specified node will be attached to
  36538. */
  36539. attach(target: Mesh): void;
  36540. /**
  36541. * Detaches the behavior from the mesh
  36542. */
  36543. detach(): void;
  36544. }
  36545. }
  36546. declare module BABYLON {
  36547. /**
  36548. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36549. */
  36550. export class FadeInOutBehavior implements Behavior<Mesh> {
  36551. /**
  36552. * Time in milliseconds to delay before fading in (Default: 0)
  36553. */
  36554. delay: number;
  36555. /**
  36556. * Time in milliseconds for the mesh to fade in (Default: 300)
  36557. */
  36558. fadeInTime: number;
  36559. private _millisecondsPerFrame;
  36560. private _hovered;
  36561. private _hoverValue;
  36562. private _ownerNode;
  36563. /**
  36564. * Instatiates the FadeInOutBehavior
  36565. */
  36566. constructor();
  36567. /**
  36568. * The name of the behavior
  36569. */
  36570. readonly name: string;
  36571. /**
  36572. * Initializes the behavior
  36573. */
  36574. init(): void;
  36575. /**
  36576. * Attaches the fade behavior on the passed in mesh
  36577. * @param ownerNode The mesh that will be faded in/out once attached
  36578. */
  36579. attach(ownerNode: Mesh): void;
  36580. /**
  36581. * Detaches the behavior from the mesh
  36582. */
  36583. detach(): void;
  36584. /**
  36585. * Triggers the mesh to begin fading in or out
  36586. * @param value if the object should fade in or out (true to fade in)
  36587. */
  36588. fadeIn(value: boolean): void;
  36589. private _update;
  36590. private _setAllVisibility;
  36591. }
  36592. }
  36593. declare module BABYLON {
  36594. /**
  36595. * Class containing a set of static utilities functions for managing Pivots
  36596. * @hidden
  36597. */
  36598. export class PivotTools {
  36599. private static _PivotCached;
  36600. private static _OldPivotPoint;
  36601. private static _PivotTranslation;
  36602. private static _PivotTmpVector;
  36603. /** @hidden */
  36604. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36605. /** @hidden */
  36606. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36607. }
  36608. }
  36609. declare module BABYLON {
  36610. /**
  36611. * Class containing static functions to help procedurally build meshes
  36612. */
  36613. export class PlaneBuilder {
  36614. /**
  36615. * Creates a plane mesh
  36616. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36617. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36618. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36620. * * 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
  36621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36622. * @param name defines the name of the mesh
  36623. * @param options defines the options used to create the mesh
  36624. * @param scene defines the hosting scene
  36625. * @returns the plane mesh
  36626. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36627. */
  36628. static CreatePlane(name: string, options: {
  36629. size?: number;
  36630. width?: number;
  36631. height?: number;
  36632. sideOrientation?: number;
  36633. frontUVs?: Vector4;
  36634. backUVs?: Vector4;
  36635. updatable?: boolean;
  36636. sourcePlane?: Plane;
  36637. }, scene?: Nullable<Scene>): Mesh;
  36638. }
  36639. }
  36640. declare module BABYLON {
  36641. /**
  36642. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36643. */
  36644. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36645. private static _AnyMouseID;
  36646. /**
  36647. * Abstract mesh the behavior is set on
  36648. */
  36649. attachedNode: AbstractMesh;
  36650. private _dragPlane;
  36651. private _scene;
  36652. private _pointerObserver;
  36653. private _beforeRenderObserver;
  36654. private static _planeScene;
  36655. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36656. /**
  36657. * 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)
  36658. */
  36659. maxDragAngle: number;
  36660. /**
  36661. * @hidden
  36662. */
  36663. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36664. /**
  36665. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36666. */
  36667. currentDraggingPointerID: number;
  36668. /**
  36669. * The last position where the pointer hit the drag plane in world space
  36670. */
  36671. lastDragPosition: Vector3;
  36672. /**
  36673. * If the behavior is currently in a dragging state
  36674. */
  36675. dragging: boolean;
  36676. /**
  36677. * 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)
  36678. */
  36679. dragDeltaRatio: number;
  36680. /**
  36681. * If the drag plane orientation should be updated during the dragging (Default: true)
  36682. */
  36683. updateDragPlane: boolean;
  36684. private _debugMode;
  36685. private _moving;
  36686. /**
  36687. * Fires each time the attached mesh is dragged with the pointer
  36688. * * delta between last drag position and current drag position in world space
  36689. * * dragDistance along the drag axis
  36690. * * dragPlaneNormal normal of the current drag plane used during the drag
  36691. * * dragPlanePoint in world space where the drag intersects the drag plane
  36692. */
  36693. onDragObservable: Observable<{
  36694. delta: Vector3;
  36695. dragPlanePoint: Vector3;
  36696. dragPlaneNormal: Vector3;
  36697. dragDistance: number;
  36698. pointerId: number;
  36699. }>;
  36700. /**
  36701. * Fires each time a drag begins (eg. mouse down on mesh)
  36702. */
  36703. onDragStartObservable: Observable<{
  36704. dragPlanePoint: Vector3;
  36705. pointerId: number;
  36706. }>;
  36707. /**
  36708. * Fires each time a drag ends (eg. mouse release after drag)
  36709. */
  36710. onDragEndObservable: Observable<{
  36711. dragPlanePoint: Vector3;
  36712. pointerId: number;
  36713. }>;
  36714. /**
  36715. * If the attached mesh should be moved when dragged
  36716. */
  36717. moveAttached: boolean;
  36718. /**
  36719. * If the drag behavior will react to drag events (Default: true)
  36720. */
  36721. enabled: boolean;
  36722. /**
  36723. * If pointer events should start and release the drag (Default: true)
  36724. */
  36725. startAndReleaseDragOnPointerEvents: boolean;
  36726. /**
  36727. * If camera controls should be detached during the drag
  36728. */
  36729. detachCameraControls: boolean;
  36730. /**
  36731. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36732. */
  36733. useObjectOrienationForDragging: boolean;
  36734. private _options;
  36735. /**
  36736. * Creates a pointer drag behavior that can be attached to a mesh
  36737. * @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)
  36738. */
  36739. constructor(options?: {
  36740. dragAxis?: Vector3;
  36741. dragPlaneNormal?: Vector3;
  36742. });
  36743. /**
  36744. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36745. */
  36746. validateDrag: (targetPosition: Vector3) => boolean;
  36747. /**
  36748. * The name of the behavior
  36749. */
  36750. readonly name: string;
  36751. /**
  36752. * Initializes the behavior
  36753. */
  36754. init(): void;
  36755. private _tmpVector;
  36756. private _alternatePickedPoint;
  36757. private _worldDragAxis;
  36758. private _targetPosition;
  36759. private _attachedElement;
  36760. /**
  36761. * Attaches the drag behavior the passed in mesh
  36762. * @param ownerNode The mesh that will be dragged around once attached
  36763. * @param predicate Predicate to use for pick filtering
  36764. */
  36765. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36766. /**
  36767. * Force relase the drag action by code.
  36768. */
  36769. releaseDrag(): void;
  36770. private _startDragRay;
  36771. private _lastPointerRay;
  36772. /**
  36773. * Simulates the start of a pointer drag event on the behavior
  36774. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36775. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36776. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36777. */
  36778. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36779. private _startDrag;
  36780. private _dragDelta;
  36781. private _moveDrag;
  36782. private _pickWithRayOnDragPlane;
  36783. private _pointA;
  36784. private _pointB;
  36785. private _pointC;
  36786. private _lineA;
  36787. private _lineB;
  36788. private _localAxis;
  36789. private _lookAt;
  36790. private _updateDragPlanePosition;
  36791. /**
  36792. * Detaches the behavior from the mesh
  36793. */
  36794. detach(): void;
  36795. }
  36796. }
  36797. declare module BABYLON {
  36798. /**
  36799. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36800. */
  36801. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36802. private _dragBehaviorA;
  36803. private _dragBehaviorB;
  36804. private _startDistance;
  36805. private _initialScale;
  36806. private _targetScale;
  36807. private _ownerNode;
  36808. private _sceneRenderObserver;
  36809. /**
  36810. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36811. */
  36812. constructor();
  36813. /**
  36814. * The name of the behavior
  36815. */
  36816. readonly name: string;
  36817. /**
  36818. * Initializes the behavior
  36819. */
  36820. init(): void;
  36821. private _getCurrentDistance;
  36822. /**
  36823. * Attaches the scale behavior the passed in mesh
  36824. * @param ownerNode The mesh that will be scaled around once attached
  36825. */
  36826. attach(ownerNode: Mesh): void;
  36827. /**
  36828. * Detaches the behavior from the mesh
  36829. */
  36830. detach(): void;
  36831. }
  36832. }
  36833. declare module BABYLON {
  36834. /**
  36835. * 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
  36836. */
  36837. export class SixDofDragBehavior implements Behavior<Mesh> {
  36838. private static _virtualScene;
  36839. private _ownerNode;
  36840. private _sceneRenderObserver;
  36841. private _scene;
  36842. private _targetPosition;
  36843. private _virtualOriginMesh;
  36844. private _virtualDragMesh;
  36845. private _pointerObserver;
  36846. private _moving;
  36847. private _startingOrientation;
  36848. /**
  36849. * 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)
  36850. */
  36851. private zDragFactor;
  36852. /**
  36853. * If the object should rotate to face the drag origin
  36854. */
  36855. rotateDraggedObject: boolean;
  36856. /**
  36857. * If the behavior is currently in a dragging state
  36858. */
  36859. dragging: boolean;
  36860. /**
  36861. * 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)
  36862. */
  36863. dragDeltaRatio: number;
  36864. /**
  36865. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36866. */
  36867. currentDraggingPointerID: number;
  36868. /**
  36869. * If camera controls should be detached during the drag
  36870. */
  36871. detachCameraControls: boolean;
  36872. /**
  36873. * Fires each time a drag starts
  36874. */
  36875. onDragStartObservable: Observable<{}>;
  36876. /**
  36877. * Fires each time a drag ends (eg. mouse release after drag)
  36878. */
  36879. onDragEndObservable: Observable<{}>;
  36880. /**
  36881. * 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
  36882. */
  36883. constructor();
  36884. /**
  36885. * The name of the behavior
  36886. */
  36887. readonly name: string;
  36888. /**
  36889. * Initializes the behavior
  36890. */
  36891. init(): void;
  36892. /**
  36893. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36894. */
  36895. private readonly _pointerCamera;
  36896. /**
  36897. * Attaches the scale behavior the passed in mesh
  36898. * @param ownerNode The mesh that will be scaled around once attached
  36899. */
  36900. attach(ownerNode: Mesh): void;
  36901. /**
  36902. * Detaches the behavior from the mesh
  36903. */
  36904. detach(): void;
  36905. }
  36906. }
  36907. declare module BABYLON {
  36908. /**
  36909. * Class used to apply inverse kinematics to bones
  36910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36911. */
  36912. export class BoneIKController {
  36913. private static _tmpVecs;
  36914. private static _tmpQuat;
  36915. private static _tmpMats;
  36916. /**
  36917. * Gets or sets the target mesh
  36918. */
  36919. targetMesh: AbstractMesh;
  36920. /** Gets or sets the mesh used as pole */
  36921. poleTargetMesh: AbstractMesh;
  36922. /**
  36923. * Gets or sets the bone used as pole
  36924. */
  36925. poleTargetBone: Nullable<Bone>;
  36926. /**
  36927. * Gets or sets the target position
  36928. */
  36929. targetPosition: Vector3;
  36930. /**
  36931. * Gets or sets the pole target position
  36932. */
  36933. poleTargetPosition: Vector3;
  36934. /**
  36935. * Gets or sets the pole target local offset
  36936. */
  36937. poleTargetLocalOffset: Vector3;
  36938. /**
  36939. * Gets or sets the pole angle
  36940. */
  36941. poleAngle: number;
  36942. /**
  36943. * Gets or sets the mesh associated with the controller
  36944. */
  36945. mesh: AbstractMesh;
  36946. /**
  36947. * 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)
  36948. */
  36949. slerpAmount: number;
  36950. private _bone1Quat;
  36951. private _bone1Mat;
  36952. private _bone2Ang;
  36953. private _bone1;
  36954. private _bone2;
  36955. private _bone1Length;
  36956. private _bone2Length;
  36957. private _maxAngle;
  36958. private _maxReach;
  36959. private _rightHandedSystem;
  36960. private _bendAxis;
  36961. private _slerping;
  36962. private _adjustRoll;
  36963. /**
  36964. * Gets or sets maximum allowed angle
  36965. */
  36966. maxAngle: number;
  36967. /**
  36968. * Creates a new BoneIKController
  36969. * @param mesh defines the mesh to control
  36970. * @param bone defines the bone to control
  36971. * @param options defines options to set up the controller
  36972. */
  36973. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36974. targetMesh?: AbstractMesh;
  36975. poleTargetMesh?: AbstractMesh;
  36976. poleTargetBone?: Bone;
  36977. poleTargetLocalOffset?: Vector3;
  36978. poleAngle?: number;
  36979. bendAxis?: Vector3;
  36980. maxAngle?: number;
  36981. slerpAmount?: number;
  36982. });
  36983. private _setMaxAngle;
  36984. /**
  36985. * Force the controller to update the bones
  36986. */
  36987. update(): void;
  36988. }
  36989. }
  36990. declare module BABYLON {
  36991. /**
  36992. * Class used to make a bone look toward a point in space
  36993. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36994. */
  36995. export class BoneLookController {
  36996. private static _tmpVecs;
  36997. private static _tmpQuat;
  36998. private static _tmpMats;
  36999. /**
  37000. * The target Vector3 that the bone will look at
  37001. */
  37002. target: Vector3;
  37003. /**
  37004. * The mesh that the bone is attached to
  37005. */
  37006. mesh: AbstractMesh;
  37007. /**
  37008. * The bone that will be looking to the target
  37009. */
  37010. bone: Bone;
  37011. /**
  37012. * The up axis of the coordinate system that is used when the bone is rotated
  37013. */
  37014. upAxis: Vector3;
  37015. /**
  37016. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37017. */
  37018. upAxisSpace: Space;
  37019. /**
  37020. * Used to make an adjustment to the yaw of the bone
  37021. */
  37022. adjustYaw: number;
  37023. /**
  37024. * Used to make an adjustment to the pitch of the bone
  37025. */
  37026. adjustPitch: number;
  37027. /**
  37028. * Used to make an adjustment to the roll of the bone
  37029. */
  37030. adjustRoll: number;
  37031. /**
  37032. * 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)
  37033. */
  37034. slerpAmount: number;
  37035. private _minYaw;
  37036. private _maxYaw;
  37037. private _minPitch;
  37038. private _maxPitch;
  37039. private _minYawSin;
  37040. private _minYawCos;
  37041. private _maxYawSin;
  37042. private _maxYawCos;
  37043. private _midYawConstraint;
  37044. private _minPitchTan;
  37045. private _maxPitchTan;
  37046. private _boneQuat;
  37047. private _slerping;
  37048. private _transformYawPitch;
  37049. private _transformYawPitchInv;
  37050. private _firstFrameSkipped;
  37051. private _yawRange;
  37052. private _fowardAxis;
  37053. /**
  37054. * Gets or sets the minimum yaw angle that the bone can look to
  37055. */
  37056. minYaw: number;
  37057. /**
  37058. * Gets or sets the maximum yaw angle that the bone can look to
  37059. */
  37060. maxYaw: number;
  37061. /**
  37062. * Gets or sets the minimum pitch angle that the bone can look to
  37063. */
  37064. minPitch: number;
  37065. /**
  37066. * Gets or sets the maximum pitch angle that the bone can look to
  37067. */
  37068. maxPitch: number;
  37069. /**
  37070. * Create a BoneLookController
  37071. * @param mesh the mesh that the bone belongs to
  37072. * @param bone the bone that will be looking to the target
  37073. * @param target the target Vector3 to look at
  37074. * @param options optional settings:
  37075. * * maxYaw: the maximum angle the bone will yaw to
  37076. * * minYaw: the minimum angle the bone will yaw to
  37077. * * maxPitch: the maximum angle the bone will pitch to
  37078. * * minPitch: the minimum angle the bone will yaw to
  37079. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37080. * * upAxis: the up axis of the coordinate system
  37081. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37082. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37083. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37084. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37085. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37086. * * adjustRoll: used to make an adjustment to the roll of the bone
  37087. **/
  37088. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37089. maxYaw?: number;
  37090. minYaw?: number;
  37091. maxPitch?: number;
  37092. minPitch?: number;
  37093. slerpAmount?: number;
  37094. upAxis?: Vector3;
  37095. upAxisSpace?: Space;
  37096. yawAxis?: Vector3;
  37097. pitchAxis?: Vector3;
  37098. adjustYaw?: number;
  37099. adjustPitch?: number;
  37100. adjustRoll?: number;
  37101. });
  37102. /**
  37103. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37104. */
  37105. update(): void;
  37106. private _getAngleDiff;
  37107. private _getAngleBetween;
  37108. private _isAngleBetween;
  37109. }
  37110. }
  37111. declare module BABYLON {
  37112. /**
  37113. * Manage the gamepad inputs to control an arc rotate camera.
  37114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37115. */
  37116. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37117. /**
  37118. * Defines the camera the input is attached to.
  37119. */
  37120. camera: ArcRotateCamera;
  37121. /**
  37122. * Defines the gamepad the input is gathering event from.
  37123. */
  37124. gamepad: Nullable<Gamepad>;
  37125. /**
  37126. * Defines the gamepad rotation sensiblity.
  37127. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37128. */
  37129. gamepadRotationSensibility: number;
  37130. /**
  37131. * Defines the gamepad move sensiblity.
  37132. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37133. */
  37134. gamepadMoveSensibility: number;
  37135. private _onGamepadConnectedObserver;
  37136. private _onGamepadDisconnectedObserver;
  37137. /**
  37138. * Attach the input controls to a specific dom element to get the input from.
  37139. * @param element Defines the element the controls should be listened from
  37140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37141. */
  37142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37143. /**
  37144. * Detach the current controls from the specified dom element.
  37145. * @param element Defines the element to stop listening the inputs from
  37146. */
  37147. detachControl(element: Nullable<HTMLElement>): void;
  37148. /**
  37149. * Update the current camera state depending on the inputs that have been used this frame.
  37150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37151. */
  37152. checkInputs(): void;
  37153. /**
  37154. * Gets the class name of the current intput.
  37155. * @returns the class name
  37156. */
  37157. getClassName(): string;
  37158. /**
  37159. * Get the friendly name associated with the input class.
  37160. * @returns the input friendly name
  37161. */
  37162. getSimpleName(): string;
  37163. }
  37164. }
  37165. declare module BABYLON {
  37166. interface ArcRotateCameraInputsManager {
  37167. /**
  37168. * Add orientation input support to the input manager.
  37169. * @returns the current input manager
  37170. */
  37171. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37172. }
  37173. /**
  37174. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37176. */
  37177. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37178. /**
  37179. * Defines the camera the input is attached to.
  37180. */
  37181. camera: ArcRotateCamera;
  37182. /**
  37183. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37184. */
  37185. alphaCorrection: number;
  37186. /**
  37187. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37188. */
  37189. gammaCorrection: number;
  37190. private _alpha;
  37191. private _gamma;
  37192. private _dirty;
  37193. private _deviceOrientationHandler;
  37194. /**
  37195. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37196. */
  37197. constructor();
  37198. /**
  37199. * Attach the input controls to a specific dom element to get the input from.
  37200. * @param element Defines the element the controls should be listened from
  37201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37202. */
  37203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37204. /** @hidden */
  37205. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37206. /**
  37207. * Update the current camera state depending on the inputs that have been used this frame.
  37208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37209. */
  37210. checkInputs(): void;
  37211. /**
  37212. * Detach the current controls from the specified dom element.
  37213. * @param element Defines the element to stop listening the inputs from
  37214. */
  37215. detachControl(element: Nullable<HTMLElement>): void;
  37216. /**
  37217. * Gets the class name of the current intput.
  37218. * @returns the class name
  37219. */
  37220. getClassName(): string;
  37221. /**
  37222. * Get the friendly name associated with the input class.
  37223. * @returns the input friendly name
  37224. */
  37225. getSimpleName(): string;
  37226. }
  37227. }
  37228. declare module BABYLON {
  37229. /**
  37230. * Listen to mouse events to control the camera.
  37231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37232. */
  37233. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37234. /**
  37235. * Defines the camera the input is attached to.
  37236. */
  37237. camera: FlyCamera;
  37238. /**
  37239. * Defines if touch is enabled. (Default is true.)
  37240. */
  37241. touchEnabled: boolean;
  37242. /**
  37243. * Defines the buttons associated with the input to handle camera rotation.
  37244. */
  37245. buttons: number[];
  37246. /**
  37247. * Assign buttons for Yaw control.
  37248. */
  37249. buttonsYaw: number[];
  37250. /**
  37251. * Assign buttons for Pitch control.
  37252. */
  37253. buttonsPitch: number[];
  37254. /**
  37255. * Assign buttons for Roll control.
  37256. */
  37257. buttonsRoll: number[];
  37258. /**
  37259. * Detect if any button is being pressed while mouse is moved.
  37260. * -1 = Mouse locked.
  37261. * 0 = Left button.
  37262. * 1 = Middle Button.
  37263. * 2 = Right Button.
  37264. */
  37265. activeButton: number;
  37266. /**
  37267. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37268. * Higher values reduce its sensitivity.
  37269. */
  37270. angularSensibility: number;
  37271. private _mousemoveCallback;
  37272. private _observer;
  37273. private _rollObserver;
  37274. private previousPosition;
  37275. private noPreventDefault;
  37276. private element;
  37277. /**
  37278. * Listen to mouse events to control the camera.
  37279. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37281. */
  37282. constructor(touchEnabled?: boolean);
  37283. /**
  37284. * Attach the mouse control to the HTML DOM element.
  37285. * @param element Defines the element that listens to the input events.
  37286. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37287. */
  37288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37289. /**
  37290. * Detach the current controls from the specified dom element.
  37291. * @param element Defines the element to stop listening the inputs from
  37292. */
  37293. detachControl(element: Nullable<HTMLElement>): void;
  37294. /**
  37295. * Gets the class name of the current input.
  37296. * @returns the class name.
  37297. */
  37298. getClassName(): string;
  37299. /**
  37300. * Get the friendly name associated with the input class.
  37301. * @returns the input's friendly name.
  37302. */
  37303. getSimpleName(): string;
  37304. private _pointerInput;
  37305. private _onMouseMove;
  37306. /**
  37307. * Rotate camera by mouse offset.
  37308. */
  37309. private rotateCamera;
  37310. }
  37311. }
  37312. declare module BABYLON {
  37313. /**
  37314. * Default Inputs manager for the FlyCamera.
  37315. * It groups all the default supported inputs for ease of use.
  37316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37317. */
  37318. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37319. /**
  37320. * Instantiates a new FlyCameraInputsManager.
  37321. * @param camera Defines the camera the inputs belong to.
  37322. */
  37323. constructor(camera: FlyCamera);
  37324. /**
  37325. * Add keyboard input support to the input manager.
  37326. * @returns the new FlyCameraKeyboardMoveInput().
  37327. */
  37328. addKeyboard(): FlyCameraInputsManager;
  37329. /**
  37330. * Add mouse input support to the input manager.
  37331. * @param touchEnabled Enable touch screen support.
  37332. * @returns the new FlyCameraMouseInput().
  37333. */
  37334. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37335. }
  37336. }
  37337. declare module BABYLON {
  37338. /**
  37339. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37340. * such as in a 3D Space Shooter or a Flight Simulator.
  37341. */
  37342. export class FlyCamera extends TargetCamera {
  37343. /**
  37344. * Define the collision ellipsoid of the camera.
  37345. * This is helpful for simulating a camera body, like a player's body.
  37346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37347. */
  37348. ellipsoid: Vector3;
  37349. /**
  37350. * Define an offset for the position of the ellipsoid around the camera.
  37351. * This can be helpful if the camera is attached away from the player's body center,
  37352. * such as at its head.
  37353. */
  37354. ellipsoidOffset: Vector3;
  37355. /**
  37356. * Enable or disable collisions of the camera with the rest of the scene objects.
  37357. */
  37358. checkCollisions: boolean;
  37359. /**
  37360. * Enable or disable gravity on the camera.
  37361. */
  37362. applyGravity: boolean;
  37363. /**
  37364. * Define the current direction the camera is moving to.
  37365. */
  37366. cameraDirection: Vector3;
  37367. /**
  37368. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37369. * This overrides and empties cameraRotation.
  37370. */
  37371. rotationQuaternion: Quaternion;
  37372. /**
  37373. * Track Roll to maintain the wanted Rolling when looking around.
  37374. */
  37375. _trackRoll: number;
  37376. /**
  37377. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37378. */
  37379. rollCorrect: number;
  37380. /**
  37381. * Mimic a banked turn, Rolling the camera when Yawing.
  37382. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37383. */
  37384. bankedTurn: boolean;
  37385. /**
  37386. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37387. */
  37388. bankedTurnLimit: number;
  37389. /**
  37390. * Value of 0 disables the banked Roll.
  37391. * Value of 1 is equal to the Yaw angle in radians.
  37392. */
  37393. bankedTurnMultiplier: number;
  37394. /**
  37395. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37396. */
  37397. inputs: FlyCameraInputsManager;
  37398. /**
  37399. * Gets the input sensibility for mouse input.
  37400. * Higher values reduce sensitivity.
  37401. */
  37402. /**
  37403. * Sets the input sensibility for a mouse input.
  37404. * Higher values reduce sensitivity.
  37405. */
  37406. angularSensibility: number;
  37407. /**
  37408. * Get the keys for camera movement forward.
  37409. */
  37410. /**
  37411. * Set the keys for camera movement forward.
  37412. */
  37413. keysForward: number[];
  37414. /**
  37415. * Get the keys for camera movement backward.
  37416. */
  37417. keysBackward: number[];
  37418. /**
  37419. * Get the keys for camera movement up.
  37420. */
  37421. /**
  37422. * Set the keys for camera movement up.
  37423. */
  37424. keysUp: number[];
  37425. /**
  37426. * Get the keys for camera movement down.
  37427. */
  37428. /**
  37429. * Set the keys for camera movement down.
  37430. */
  37431. keysDown: number[];
  37432. /**
  37433. * Get the keys for camera movement left.
  37434. */
  37435. /**
  37436. * Set the keys for camera movement left.
  37437. */
  37438. keysLeft: number[];
  37439. /**
  37440. * Set the keys for camera movement right.
  37441. */
  37442. /**
  37443. * Set the keys for camera movement right.
  37444. */
  37445. keysRight: number[];
  37446. /**
  37447. * Event raised when the camera collides with a mesh in the scene.
  37448. */
  37449. onCollide: (collidedMesh: AbstractMesh) => void;
  37450. private _collider;
  37451. private _needMoveForGravity;
  37452. private _oldPosition;
  37453. private _diffPosition;
  37454. private _newPosition;
  37455. /** @hidden */
  37456. _localDirection: Vector3;
  37457. /** @hidden */
  37458. _transformedDirection: Vector3;
  37459. /**
  37460. * Instantiates a FlyCamera.
  37461. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37462. * such as in a 3D Space Shooter or a Flight Simulator.
  37463. * @param name Define the name of the camera in the scene.
  37464. * @param position Define the starting position of the camera in the scene.
  37465. * @param scene Define the scene the camera belongs to.
  37466. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37467. */
  37468. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37469. /**
  37470. * Attach a control to the HTML DOM element.
  37471. * @param element Defines the element that listens to the input events.
  37472. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37473. */
  37474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37475. /**
  37476. * Detach a control from the HTML DOM element.
  37477. * The camera will stop reacting to that input.
  37478. * @param element Defines the element that listens to the input events.
  37479. */
  37480. detachControl(element: HTMLElement): void;
  37481. private _collisionMask;
  37482. /**
  37483. * Get the mask that the camera ignores in collision events.
  37484. */
  37485. /**
  37486. * Set the mask that the camera ignores in collision events.
  37487. */
  37488. collisionMask: number;
  37489. /** @hidden */
  37490. _collideWithWorld(displacement: Vector3): void;
  37491. /** @hidden */
  37492. private _onCollisionPositionChange;
  37493. /** @hidden */
  37494. _checkInputs(): void;
  37495. /** @hidden */
  37496. _decideIfNeedsToMove(): boolean;
  37497. /** @hidden */
  37498. _updatePosition(): void;
  37499. /**
  37500. * Restore the Roll to its target value at the rate specified.
  37501. * @param rate - Higher means slower restoring.
  37502. * @hidden
  37503. */
  37504. restoreRoll(rate: number): void;
  37505. /**
  37506. * Destroy the camera and release the current resources held by it.
  37507. */
  37508. dispose(): void;
  37509. /**
  37510. * Get the current object class name.
  37511. * @returns the class name.
  37512. */
  37513. getClassName(): string;
  37514. }
  37515. }
  37516. declare module BABYLON {
  37517. /**
  37518. * Listen to keyboard events to control the camera.
  37519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37520. */
  37521. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37522. /**
  37523. * Defines the camera the input is attached to.
  37524. */
  37525. camera: FlyCamera;
  37526. /**
  37527. * The list of keyboard keys used to control the forward move of the camera.
  37528. */
  37529. keysForward: number[];
  37530. /**
  37531. * The list of keyboard keys used to control the backward move of the camera.
  37532. */
  37533. keysBackward: number[];
  37534. /**
  37535. * The list of keyboard keys used to control the forward move of the camera.
  37536. */
  37537. keysUp: number[];
  37538. /**
  37539. * The list of keyboard keys used to control the backward move of the camera.
  37540. */
  37541. keysDown: number[];
  37542. /**
  37543. * The list of keyboard keys used to control the right strafe move of the camera.
  37544. */
  37545. keysRight: number[];
  37546. /**
  37547. * The list of keyboard keys used to control the left strafe move of the camera.
  37548. */
  37549. keysLeft: number[];
  37550. private _keys;
  37551. private _onCanvasBlurObserver;
  37552. private _onKeyboardObserver;
  37553. private _engine;
  37554. private _scene;
  37555. /**
  37556. * Attach the input controls to a specific dom element to get the input from.
  37557. * @param element Defines the element the controls should be listened from
  37558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37559. */
  37560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37561. /**
  37562. * Detach the current controls from the specified dom element.
  37563. * @param element Defines the element to stop listening the inputs from
  37564. */
  37565. detachControl(element: Nullable<HTMLElement>): void;
  37566. /**
  37567. * Gets the class name of the current intput.
  37568. * @returns the class name
  37569. */
  37570. getClassName(): string;
  37571. /** @hidden */
  37572. _onLostFocus(e: FocusEvent): void;
  37573. /**
  37574. * Get the friendly name associated with the input class.
  37575. * @returns the input friendly name
  37576. */
  37577. getSimpleName(): string;
  37578. /**
  37579. * Update the current camera state depending on the inputs that have been used this frame.
  37580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37581. */
  37582. checkInputs(): void;
  37583. }
  37584. }
  37585. declare module BABYLON {
  37586. /**
  37587. * Manage the mouse wheel inputs to control a follow camera.
  37588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37589. */
  37590. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37591. /**
  37592. * Defines the camera the input is attached to.
  37593. */
  37594. camera: FollowCamera;
  37595. /**
  37596. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37597. */
  37598. axisControlRadius: boolean;
  37599. /**
  37600. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37601. */
  37602. axisControlHeight: boolean;
  37603. /**
  37604. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37605. */
  37606. axisControlRotation: boolean;
  37607. /**
  37608. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37609. * relation to mouseWheel events.
  37610. */
  37611. wheelPrecision: number;
  37612. /**
  37613. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37614. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37615. */
  37616. wheelDeltaPercentage: number;
  37617. private _wheel;
  37618. private _observer;
  37619. /**
  37620. * Attach the input controls to a specific dom element to get the input from.
  37621. * @param element Defines the element the controls should be listened from
  37622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37623. */
  37624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37625. /**
  37626. * Detach the current controls from the specified dom element.
  37627. * @param element Defines the element to stop listening the inputs from
  37628. */
  37629. detachControl(element: Nullable<HTMLElement>): void;
  37630. /**
  37631. * Gets the class name of the current intput.
  37632. * @returns the class name
  37633. */
  37634. getClassName(): string;
  37635. /**
  37636. * Get the friendly name associated with the input class.
  37637. * @returns the input friendly name
  37638. */
  37639. getSimpleName(): string;
  37640. }
  37641. }
  37642. declare module BABYLON {
  37643. /**
  37644. * Manage the pointers inputs to control an follow camera.
  37645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37646. */
  37647. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37648. /**
  37649. * Defines the camera the input is attached to.
  37650. */
  37651. camera: FollowCamera;
  37652. /**
  37653. * Gets the class name of the current input.
  37654. * @returns the class name
  37655. */
  37656. getClassName(): string;
  37657. /**
  37658. * Defines the pointer angular sensibility along the X axis or how fast is
  37659. * the camera rotating.
  37660. * A negative number will reverse the axis direction.
  37661. */
  37662. angularSensibilityX: number;
  37663. /**
  37664. * Defines the pointer angular sensibility along the Y axis or how fast is
  37665. * the camera rotating.
  37666. * A negative number will reverse the axis direction.
  37667. */
  37668. angularSensibilityY: number;
  37669. /**
  37670. * Defines the pointer pinch precision or how fast is the camera zooming.
  37671. * A negative number will reverse the axis direction.
  37672. */
  37673. pinchPrecision: number;
  37674. /**
  37675. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37676. * from 0.
  37677. * It defines the percentage of current camera.radius to use as delta when
  37678. * pinch zoom is used.
  37679. */
  37680. pinchDeltaPercentage: number;
  37681. /**
  37682. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37683. */
  37684. axisXControlRadius: boolean;
  37685. /**
  37686. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37687. */
  37688. axisXControlHeight: boolean;
  37689. /**
  37690. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37691. */
  37692. axisXControlRotation: boolean;
  37693. /**
  37694. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37695. */
  37696. axisYControlRadius: boolean;
  37697. /**
  37698. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37699. */
  37700. axisYControlHeight: boolean;
  37701. /**
  37702. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37703. */
  37704. axisYControlRotation: boolean;
  37705. /**
  37706. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37707. */
  37708. axisPinchControlRadius: boolean;
  37709. /**
  37710. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37711. */
  37712. axisPinchControlHeight: boolean;
  37713. /**
  37714. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37715. */
  37716. axisPinchControlRotation: boolean;
  37717. /**
  37718. * Log error messages if basic misconfiguration has occurred.
  37719. */
  37720. warningEnable: boolean;
  37721. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37722. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37723. private _warningCounter;
  37724. private _warning;
  37725. }
  37726. }
  37727. declare module BABYLON {
  37728. /**
  37729. * Default Inputs manager for the FollowCamera.
  37730. * It groups all the default supported inputs for ease of use.
  37731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37732. */
  37733. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37734. /**
  37735. * Instantiates a new FollowCameraInputsManager.
  37736. * @param camera Defines the camera the inputs belong to
  37737. */
  37738. constructor(camera: FollowCamera);
  37739. /**
  37740. * Add keyboard input support to the input manager.
  37741. * @returns the current input manager
  37742. */
  37743. addKeyboard(): FollowCameraInputsManager;
  37744. /**
  37745. * Add mouse wheel input support to the input manager.
  37746. * @returns the current input manager
  37747. */
  37748. addMouseWheel(): FollowCameraInputsManager;
  37749. /**
  37750. * Add pointers input support to the input manager.
  37751. * @returns the current input manager
  37752. */
  37753. addPointers(): FollowCameraInputsManager;
  37754. /**
  37755. * Add orientation input support to the input manager.
  37756. * @returns the current input manager
  37757. */
  37758. addVRDeviceOrientation(): FollowCameraInputsManager;
  37759. }
  37760. }
  37761. declare module BABYLON {
  37762. /**
  37763. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37764. * an arc rotate version arcFollowCamera are available.
  37765. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37766. */
  37767. export class FollowCamera extends TargetCamera {
  37768. /**
  37769. * Distance the follow camera should follow an object at
  37770. */
  37771. radius: number;
  37772. /**
  37773. * Minimum allowed distance of the camera to the axis of rotation
  37774. * (The camera can not get closer).
  37775. * This can help limiting how the Camera is able to move in the scene.
  37776. */
  37777. lowerRadiusLimit: Nullable<number>;
  37778. /**
  37779. * Maximum allowed distance of the camera to the axis of rotation
  37780. * (The camera can not get further).
  37781. * This can help limiting how the Camera is able to move in the scene.
  37782. */
  37783. upperRadiusLimit: Nullable<number>;
  37784. /**
  37785. * Define a rotation offset between the camera and the object it follows
  37786. */
  37787. rotationOffset: number;
  37788. /**
  37789. * Minimum allowed angle to camera position relative to target object.
  37790. * This can help limiting how the Camera is able to move in the scene.
  37791. */
  37792. lowerRotationOffsetLimit: Nullable<number>;
  37793. /**
  37794. * Maximum allowed angle to camera position relative to target object.
  37795. * This can help limiting how the Camera is able to move in the scene.
  37796. */
  37797. upperRotationOffsetLimit: Nullable<number>;
  37798. /**
  37799. * Define a height offset between the camera and the object it follows.
  37800. * It can help following an object from the top (like a car chaing a plane)
  37801. */
  37802. heightOffset: number;
  37803. /**
  37804. * Minimum allowed height of camera position relative to target object.
  37805. * This can help limiting how the Camera is able to move in the scene.
  37806. */
  37807. lowerHeightOffsetLimit: Nullable<number>;
  37808. /**
  37809. * Maximum allowed height of camera position relative to target object.
  37810. * This can help limiting how the Camera is able to move in the scene.
  37811. */
  37812. upperHeightOffsetLimit: Nullable<number>;
  37813. /**
  37814. * Define how fast the camera can accelerate to follow it s target.
  37815. */
  37816. cameraAcceleration: number;
  37817. /**
  37818. * Define the speed limit of the camera following an object.
  37819. */
  37820. maxCameraSpeed: number;
  37821. /**
  37822. * Define the target of the camera.
  37823. */
  37824. lockedTarget: Nullable<AbstractMesh>;
  37825. /**
  37826. * Defines the input associated with the camera.
  37827. */
  37828. inputs: FollowCameraInputsManager;
  37829. /**
  37830. * Instantiates the follow camera.
  37831. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37832. * @param name Define the name of the camera in the scene
  37833. * @param position Define the position of the camera
  37834. * @param scene Define the scene the camera belong to
  37835. * @param lockedTarget Define the target of the camera
  37836. */
  37837. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37838. private _follow;
  37839. /**
  37840. * Attached controls to the current camera.
  37841. * @param element Defines the element the controls should be listened from
  37842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37843. */
  37844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37845. /**
  37846. * Detach the current controls from the camera.
  37847. * The camera will stop reacting to inputs.
  37848. * @param element Defines the element to stop listening the inputs from
  37849. */
  37850. detachControl(element: HTMLElement): void;
  37851. /** @hidden */
  37852. _checkInputs(): void;
  37853. private _checkLimits;
  37854. /**
  37855. * Gets the camera class name.
  37856. * @returns the class name
  37857. */
  37858. getClassName(): string;
  37859. }
  37860. /**
  37861. * Arc Rotate version of the follow camera.
  37862. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37864. */
  37865. export class ArcFollowCamera extends TargetCamera {
  37866. /** The longitudinal angle of the camera */
  37867. alpha: number;
  37868. /** The latitudinal angle of the camera */
  37869. beta: number;
  37870. /** The radius of the camera from its target */
  37871. radius: number;
  37872. /** Define the camera target (the messh it should follow) */
  37873. target: Nullable<AbstractMesh>;
  37874. private _cartesianCoordinates;
  37875. /**
  37876. * Instantiates a new ArcFollowCamera
  37877. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37878. * @param name Define the name of the camera
  37879. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37880. * @param beta Define the rotation angle of the camera around the elevation axis
  37881. * @param radius Define the radius of the camera from its target point
  37882. * @param target Define the target of the camera
  37883. * @param scene Define the scene the camera belongs to
  37884. */
  37885. constructor(name: string,
  37886. /** The longitudinal angle of the camera */
  37887. alpha: number,
  37888. /** The latitudinal angle of the camera */
  37889. beta: number,
  37890. /** The radius of the camera from its target */
  37891. radius: number,
  37892. /** Define the camera target (the messh it should follow) */
  37893. target: Nullable<AbstractMesh>, scene: Scene);
  37894. private _follow;
  37895. /** @hidden */
  37896. _checkInputs(): void;
  37897. /**
  37898. * Returns the class name of the object.
  37899. * It is mostly used internally for serialization purposes.
  37900. */
  37901. getClassName(): string;
  37902. }
  37903. }
  37904. declare module BABYLON {
  37905. /**
  37906. * Manage the keyboard inputs to control the movement of a follow camera.
  37907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37908. */
  37909. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37910. /**
  37911. * Defines the camera the input is attached to.
  37912. */
  37913. camera: FollowCamera;
  37914. /**
  37915. * Defines the list of key codes associated with the up action (increase heightOffset)
  37916. */
  37917. keysHeightOffsetIncr: number[];
  37918. /**
  37919. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37920. */
  37921. keysHeightOffsetDecr: number[];
  37922. /**
  37923. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37924. */
  37925. keysHeightOffsetModifierAlt: boolean;
  37926. /**
  37927. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37928. */
  37929. keysHeightOffsetModifierCtrl: boolean;
  37930. /**
  37931. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37932. */
  37933. keysHeightOffsetModifierShift: boolean;
  37934. /**
  37935. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37936. */
  37937. keysRotationOffsetIncr: number[];
  37938. /**
  37939. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37940. */
  37941. keysRotationOffsetDecr: number[];
  37942. /**
  37943. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37944. */
  37945. keysRotationOffsetModifierAlt: boolean;
  37946. /**
  37947. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37948. */
  37949. keysRotationOffsetModifierCtrl: boolean;
  37950. /**
  37951. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37952. */
  37953. keysRotationOffsetModifierShift: boolean;
  37954. /**
  37955. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37956. */
  37957. keysRadiusIncr: number[];
  37958. /**
  37959. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37960. */
  37961. keysRadiusDecr: number[];
  37962. /**
  37963. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37964. */
  37965. keysRadiusModifierAlt: boolean;
  37966. /**
  37967. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37968. */
  37969. keysRadiusModifierCtrl: boolean;
  37970. /**
  37971. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37972. */
  37973. keysRadiusModifierShift: boolean;
  37974. /**
  37975. * Defines the rate of change of heightOffset.
  37976. */
  37977. heightSensibility: number;
  37978. /**
  37979. * Defines the rate of change of rotationOffset.
  37980. */
  37981. rotationSensibility: number;
  37982. /**
  37983. * Defines the rate of change of radius.
  37984. */
  37985. radiusSensibility: number;
  37986. private _keys;
  37987. private _ctrlPressed;
  37988. private _altPressed;
  37989. private _shiftPressed;
  37990. private _onCanvasBlurObserver;
  37991. private _onKeyboardObserver;
  37992. private _engine;
  37993. private _scene;
  37994. /**
  37995. * Attach the input controls to a specific dom element to get the input from.
  37996. * @param element Defines the element the controls should be listened from
  37997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37998. */
  37999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38000. /**
  38001. * Detach the current controls from the specified dom element.
  38002. * @param element Defines the element to stop listening the inputs from
  38003. */
  38004. detachControl(element: Nullable<HTMLElement>): void;
  38005. /**
  38006. * Update the current camera state depending on the inputs that have been used this frame.
  38007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38008. */
  38009. checkInputs(): void;
  38010. /**
  38011. * Gets the class name of the current input.
  38012. * @returns the class name
  38013. */
  38014. getClassName(): string;
  38015. /**
  38016. * Get the friendly name associated with the input class.
  38017. * @returns the input friendly name
  38018. */
  38019. getSimpleName(): string;
  38020. /**
  38021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38022. * allow modification of the heightOffset value.
  38023. */
  38024. private _modifierHeightOffset;
  38025. /**
  38026. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38027. * allow modification of the rotationOffset value.
  38028. */
  38029. private _modifierRotationOffset;
  38030. /**
  38031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38032. * allow modification of the radius value.
  38033. */
  38034. private _modifierRadius;
  38035. }
  38036. }
  38037. declare module BABYLON {
  38038. interface FreeCameraInputsManager {
  38039. /**
  38040. * @hidden
  38041. */
  38042. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38043. /**
  38044. * Add orientation input support to the input manager.
  38045. * @returns the current input manager
  38046. */
  38047. addDeviceOrientation(): FreeCameraInputsManager;
  38048. }
  38049. /**
  38050. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38051. * Screen rotation is taken into account.
  38052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38053. */
  38054. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38055. private _camera;
  38056. private _screenOrientationAngle;
  38057. private _constantTranform;
  38058. private _screenQuaternion;
  38059. private _alpha;
  38060. private _beta;
  38061. private _gamma;
  38062. /**
  38063. * Can be used to detect if a device orientation sensor is availible on a device
  38064. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38065. * @returns a promise that will resolve on orientation change
  38066. */
  38067. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38068. /**
  38069. * @hidden
  38070. */
  38071. _onDeviceOrientationChangedObservable: Observable<void>;
  38072. /**
  38073. * Instantiates a new input
  38074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38075. */
  38076. constructor();
  38077. /**
  38078. * Define the camera controlled by the input.
  38079. */
  38080. camera: FreeCamera;
  38081. /**
  38082. * Attach the input controls to a specific dom element to get the input from.
  38083. * @param element Defines the element the controls should be listened from
  38084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38085. */
  38086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38087. private _orientationChanged;
  38088. private _deviceOrientation;
  38089. /**
  38090. * Detach the current controls from the specified dom element.
  38091. * @param element Defines the element to stop listening the inputs from
  38092. */
  38093. detachControl(element: Nullable<HTMLElement>): void;
  38094. /**
  38095. * Update the current camera state depending on the inputs that have been used this frame.
  38096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38097. */
  38098. checkInputs(): void;
  38099. /**
  38100. * Gets the class name of the current intput.
  38101. * @returns the class name
  38102. */
  38103. getClassName(): string;
  38104. /**
  38105. * Get the friendly name associated with the input class.
  38106. * @returns the input friendly name
  38107. */
  38108. getSimpleName(): string;
  38109. }
  38110. }
  38111. declare module BABYLON {
  38112. /**
  38113. * Manage the gamepad inputs to control a free camera.
  38114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38115. */
  38116. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38117. /**
  38118. * Define the camera the input is attached to.
  38119. */
  38120. camera: FreeCamera;
  38121. /**
  38122. * Define the Gamepad controlling the input
  38123. */
  38124. gamepad: Nullable<Gamepad>;
  38125. /**
  38126. * Defines the gamepad rotation sensiblity.
  38127. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38128. */
  38129. gamepadAngularSensibility: number;
  38130. /**
  38131. * Defines the gamepad move sensiblity.
  38132. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38133. */
  38134. gamepadMoveSensibility: number;
  38135. private _onGamepadConnectedObserver;
  38136. private _onGamepadDisconnectedObserver;
  38137. private _cameraTransform;
  38138. private _deltaTransform;
  38139. private _vector3;
  38140. private _vector2;
  38141. /**
  38142. * Attach the input controls to a specific dom element to get the input from.
  38143. * @param element Defines the element the controls should be listened from
  38144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38145. */
  38146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38147. /**
  38148. * Detach the current controls from the specified dom element.
  38149. * @param element Defines the element to stop listening the inputs from
  38150. */
  38151. detachControl(element: Nullable<HTMLElement>): void;
  38152. /**
  38153. * Update the current camera state depending on the inputs that have been used this frame.
  38154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38155. */
  38156. checkInputs(): void;
  38157. /**
  38158. * Gets the class name of the current intput.
  38159. * @returns the class name
  38160. */
  38161. getClassName(): string;
  38162. /**
  38163. * Get the friendly name associated with the input class.
  38164. * @returns the input friendly name
  38165. */
  38166. getSimpleName(): string;
  38167. }
  38168. }
  38169. declare module BABYLON {
  38170. /**
  38171. * Defines the potential axis of a Joystick
  38172. */
  38173. export enum JoystickAxis {
  38174. /** X axis */
  38175. X = 0,
  38176. /** Y axis */
  38177. Y = 1,
  38178. /** Z axis */
  38179. Z = 2
  38180. }
  38181. /**
  38182. * Class used to define virtual joystick (used in touch mode)
  38183. */
  38184. export class VirtualJoystick {
  38185. /**
  38186. * Gets or sets a boolean indicating that left and right values must be inverted
  38187. */
  38188. reverseLeftRight: boolean;
  38189. /**
  38190. * Gets or sets a boolean indicating that up and down values must be inverted
  38191. */
  38192. reverseUpDown: boolean;
  38193. /**
  38194. * Gets the offset value for the position (ie. the change of the position value)
  38195. */
  38196. deltaPosition: Vector3;
  38197. /**
  38198. * Gets a boolean indicating if the virtual joystick was pressed
  38199. */
  38200. pressed: boolean;
  38201. /**
  38202. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38203. */
  38204. static Canvas: Nullable<HTMLCanvasElement>;
  38205. private static _globalJoystickIndex;
  38206. private static vjCanvasContext;
  38207. private static vjCanvasWidth;
  38208. private static vjCanvasHeight;
  38209. private static halfWidth;
  38210. private _action;
  38211. private _axisTargetedByLeftAndRight;
  38212. private _axisTargetedByUpAndDown;
  38213. private _joystickSensibility;
  38214. private _inversedSensibility;
  38215. private _joystickPointerID;
  38216. private _joystickColor;
  38217. private _joystickPointerPos;
  38218. private _joystickPreviousPointerPos;
  38219. private _joystickPointerStartPos;
  38220. private _deltaJoystickVector;
  38221. private _leftJoystick;
  38222. private _touches;
  38223. private _onPointerDownHandlerRef;
  38224. private _onPointerMoveHandlerRef;
  38225. private _onPointerUpHandlerRef;
  38226. private _onResize;
  38227. /**
  38228. * Creates a new virtual joystick
  38229. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38230. */
  38231. constructor(leftJoystick?: boolean);
  38232. /**
  38233. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38234. * @param newJoystickSensibility defines the new sensibility
  38235. */
  38236. setJoystickSensibility(newJoystickSensibility: number): void;
  38237. private _onPointerDown;
  38238. private _onPointerMove;
  38239. private _onPointerUp;
  38240. /**
  38241. * Change the color of the virtual joystick
  38242. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38243. */
  38244. setJoystickColor(newColor: string): void;
  38245. /**
  38246. * Defines a callback to call when the joystick is touched
  38247. * @param action defines the callback
  38248. */
  38249. setActionOnTouch(action: () => any): void;
  38250. /**
  38251. * Defines which axis you'd like to control for left & right
  38252. * @param axis defines the axis to use
  38253. */
  38254. setAxisForLeftRight(axis: JoystickAxis): void;
  38255. /**
  38256. * Defines which axis you'd like to control for up & down
  38257. * @param axis defines the axis to use
  38258. */
  38259. setAxisForUpDown(axis: JoystickAxis): void;
  38260. private _drawVirtualJoystick;
  38261. /**
  38262. * Release internal HTML canvas
  38263. */
  38264. releaseCanvas(): void;
  38265. }
  38266. }
  38267. declare module BABYLON {
  38268. interface FreeCameraInputsManager {
  38269. /**
  38270. * Add virtual joystick input support to the input manager.
  38271. * @returns the current input manager
  38272. */
  38273. addVirtualJoystick(): FreeCameraInputsManager;
  38274. }
  38275. /**
  38276. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38278. */
  38279. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38280. /**
  38281. * Defines the camera the input is attached to.
  38282. */
  38283. camera: FreeCamera;
  38284. private _leftjoystick;
  38285. private _rightjoystick;
  38286. /**
  38287. * Gets the left stick of the virtual joystick.
  38288. * @returns The virtual Joystick
  38289. */
  38290. getLeftJoystick(): VirtualJoystick;
  38291. /**
  38292. * Gets the right stick of the virtual joystick.
  38293. * @returns The virtual Joystick
  38294. */
  38295. getRightJoystick(): VirtualJoystick;
  38296. /**
  38297. * Update the current camera state depending on the inputs that have been used this frame.
  38298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38299. */
  38300. checkInputs(): void;
  38301. /**
  38302. * Attach the input controls to a specific dom element to get the input from.
  38303. * @param element Defines the element the controls should be listened from
  38304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38305. */
  38306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38307. /**
  38308. * Detach the current controls from the specified dom element.
  38309. * @param element Defines the element to stop listening the inputs from
  38310. */
  38311. detachControl(element: Nullable<HTMLElement>): void;
  38312. /**
  38313. * Gets the class name of the current intput.
  38314. * @returns the class name
  38315. */
  38316. getClassName(): string;
  38317. /**
  38318. * Get the friendly name associated with the input class.
  38319. * @returns the input friendly name
  38320. */
  38321. getSimpleName(): string;
  38322. }
  38323. }
  38324. declare module BABYLON {
  38325. /**
  38326. * This represents a FPS type of camera controlled by touch.
  38327. * This is like a universal camera minus the Gamepad controls.
  38328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38329. */
  38330. export class TouchCamera extends FreeCamera {
  38331. /**
  38332. * Defines the touch sensibility for rotation.
  38333. * The higher the faster.
  38334. */
  38335. touchAngularSensibility: number;
  38336. /**
  38337. * Defines the touch sensibility for move.
  38338. * The higher the faster.
  38339. */
  38340. touchMoveSensibility: number;
  38341. /**
  38342. * Instantiates a new touch camera.
  38343. * This represents a FPS type of camera controlled by touch.
  38344. * This is like a universal camera minus the Gamepad controls.
  38345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38346. * @param name Define the name of the camera in the scene
  38347. * @param position Define the start position of the camera in the scene
  38348. * @param scene Define the scene the camera belongs to
  38349. */
  38350. constructor(name: string, position: Vector3, scene: Scene);
  38351. /**
  38352. * Gets the current object class name.
  38353. * @return the class name
  38354. */
  38355. getClassName(): string;
  38356. /** @hidden */
  38357. _setupInputs(): void;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. /**
  38362. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38363. * being tilted forward or back and left or right.
  38364. */
  38365. export class DeviceOrientationCamera extends FreeCamera {
  38366. private _initialQuaternion;
  38367. private _quaternionCache;
  38368. private _tmpDragQuaternion;
  38369. private _disablePointerInputWhenUsingDeviceOrientation;
  38370. /**
  38371. * Creates a new device orientation camera
  38372. * @param name The name of the camera
  38373. * @param position The start position camera
  38374. * @param scene The scene the camera belongs to
  38375. */
  38376. constructor(name: string, position: Vector3, scene: Scene);
  38377. /**
  38378. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38379. */
  38380. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38381. private _dragFactor;
  38382. /**
  38383. * Enabled turning on the y axis when the orientation sensor is active
  38384. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38385. */
  38386. enableHorizontalDragging(dragFactor?: number): void;
  38387. /**
  38388. * Gets the current instance class name ("DeviceOrientationCamera").
  38389. * This helps avoiding instanceof at run time.
  38390. * @returns the class name
  38391. */
  38392. getClassName(): string;
  38393. /**
  38394. * @hidden
  38395. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38396. */
  38397. _checkInputs(): void;
  38398. /**
  38399. * Reset the camera to its default orientation on the specified axis only.
  38400. * @param axis The axis to reset
  38401. */
  38402. resetToCurrentRotation(axis?: Axis): void;
  38403. }
  38404. }
  38405. declare module BABYLON {
  38406. /**
  38407. * Defines supported buttons for XBox360 compatible gamepads
  38408. */
  38409. export enum Xbox360Button {
  38410. /** A */
  38411. A = 0,
  38412. /** B */
  38413. B = 1,
  38414. /** X */
  38415. X = 2,
  38416. /** Y */
  38417. Y = 3,
  38418. /** Start */
  38419. Start = 4,
  38420. /** Back */
  38421. Back = 5,
  38422. /** Left button */
  38423. LB = 6,
  38424. /** Right button */
  38425. RB = 7,
  38426. /** Left stick */
  38427. LeftStick = 8,
  38428. /** Right stick */
  38429. RightStick = 9
  38430. }
  38431. /** Defines values for XBox360 DPad */
  38432. export enum Xbox360Dpad {
  38433. /** Up */
  38434. Up = 0,
  38435. /** Down */
  38436. Down = 1,
  38437. /** Left */
  38438. Left = 2,
  38439. /** Right */
  38440. Right = 3
  38441. }
  38442. /**
  38443. * Defines a XBox360 gamepad
  38444. */
  38445. export class Xbox360Pad extends Gamepad {
  38446. private _leftTrigger;
  38447. private _rightTrigger;
  38448. private _onlefttriggerchanged;
  38449. private _onrighttriggerchanged;
  38450. private _onbuttondown;
  38451. private _onbuttonup;
  38452. private _ondpaddown;
  38453. private _ondpadup;
  38454. /** Observable raised when a button is pressed */
  38455. onButtonDownObservable: Observable<Xbox360Button>;
  38456. /** Observable raised when a button is released */
  38457. onButtonUpObservable: Observable<Xbox360Button>;
  38458. /** Observable raised when a pad is pressed */
  38459. onPadDownObservable: Observable<Xbox360Dpad>;
  38460. /** Observable raised when a pad is released */
  38461. onPadUpObservable: Observable<Xbox360Dpad>;
  38462. private _buttonA;
  38463. private _buttonB;
  38464. private _buttonX;
  38465. private _buttonY;
  38466. private _buttonBack;
  38467. private _buttonStart;
  38468. private _buttonLB;
  38469. private _buttonRB;
  38470. private _buttonLeftStick;
  38471. private _buttonRightStick;
  38472. private _dPadUp;
  38473. private _dPadDown;
  38474. private _dPadLeft;
  38475. private _dPadRight;
  38476. private _isXboxOnePad;
  38477. /**
  38478. * Creates a new XBox360 gamepad object
  38479. * @param id defines the id of this gamepad
  38480. * @param index defines its index
  38481. * @param gamepad defines the internal HTML gamepad object
  38482. * @param xboxOne defines if it is a XBox One gamepad
  38483. */
  38484. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38485. /**
  38486. * Defines the callback to call when left trigger is pressed
  38487. * @param callback defines the callback to use
  38488. */
  38489. onlefttriggerchanged(callback: (value: number) => void): void;
  38490. /**
  38491. * Defines the callback to call when right trigger is pressed
  38492. * @param callback defines the callback to use
  38493. */
  38494. onrighttriggerchanged(callback: (value: number) => void): void;
  38495. /**
  38496. * Gets the left trigger value
  38497. */
  38498. /**
  38499. * Sets the left trigger value
  38500. */
  38501. leftTrigger: number;
  38502. /**
  38503. * Gets the right trigger value
  38504. */
  38505. /**
  38506. * Sets the right trigger value
  38507. */
  38508. rightTrigger: number;
  38509. /**
  38510. * Defines the callback to call when a button is pressed
  38511. * @param callback defines the callback to use
  38512. */
  38513. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38514. /**
  38515. * Defines the callback to call when a button is released
  38516. * @param callback defines the callback to use
  38517. */
  38518. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38519. /**
  38520. * Defines the callback to call when a pad is pressed
  38521. * @param callback defines the callback to use
  38522. */
  38523. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38524. /**
  38525. * Defines the callback to call when a pad is released
  38526. * @param callback defines the callback to use
  38527. */
  38528. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38529. private _setButtonValue;
  38530. private _setDPadValue;
  38531. /**
  38532. * Gets the value of the `A` button
  38533. */
  38534. /**
  38535. * Sets the value of the `A` button
  38536. */
  38537. buttonA: number;
  38538. /**
  38539. * Gets the value of the `B` button
  38540. */
  38541. /**
  38542. * Sets the value of the `B` button
  38543. */
  38544. buttonB: number;
  38545. /**
  38546. * Gets the value of the `X` button
  38547. */
  38548. /**
  38549. * Sets the value of the `X` button
  38550. */
  38551. buttonX: number;
  38552. /**
  38553. * Gets the value of the `Y` button
  38554. */
  38555. /**
  38556. * Sets the value of the `Y` button
  38557. */
  38558. buttonY: number;
  38559. /**
  38560. * Gets the value of the `Start` button
  38561. */
  38562. /**
  38563. * Sets the value of the `Start` button
  38564. */
  38565. buttonStart: number;
  38566. /**
  38567. * Gets the value of the `Back` button
  38568. */
  38569. /**
  38570. * Sets the value of the `Back` button
  38571. */
  38572. buttonBack: number;
  38573. /**
  38574. * Gets the value of the `Left` button
  38575. */
  38576. /**
  38577. * Sets the value of the `Left` button
  38578. */
  38579. buttonLB: number;
  38580. /**
  38581. * Gets the value of the `Right` button
  38582. */
  38583. /**
  38584. * Sets the value of the `Right` button
  38585. */
  38586. buttonRB: number;
  38587. /**
  38588. * Gets the value of the Left joystick
  38589. */
  38590. /**
  38591. * Sets the value of the Left joystick
  38592. */
  38593. buttonLeftStick: number;
  38594. /**
  38595. * Gets the value of the Right joystick
  38596. */
  38597. /**
  38598. * Sets the value of the Right joystick
  38599. */
  38600. buttonRightStick: number;
  38601. /**
  38602. * Gets the value of D-pad up
  38603. */
  38604. /**
  38605. * Sets the value of D-pad up
  38606. */
  38607. dPadUp: number;
  38608. /**
  38609. * Gets the value of D-pad down
  38610. */
  38611. /**
  38612. * Sets the value of D-pad down
  38613. */
  38614. dPadDown: number;
  38615. /**
  38616. * Gets the value of D-pad left
  38617. */
  38618. /**
  38619. * Sets the value of D-pad left
  38620. */
  38621. dPadLeft: number;
  38622. /**
  38623. * Gets the value of D-pad right
  38624. */
  38625. /**
  38626. * Sets the value of D-pad right
  38627. */
  38628. dPadRight: number;
  38629. /**
  38630. * Force the gamepad to synchronize with device values
  38631. */
  38632. update(): void;
  38633. /**
  38634. * Disposes the gamepad
  38635. */
  38636. dispose(): void;
  38637. }
  38638. }
  38639. declare module BABYLON {
  38640. /**
  38641. * Defines supported buttons for DualShock compatible gamepads
  38642. */
  38643. export enum DualShockButton {
  38644. /** Cross */
  38645. Cross = 0,
  38646. /** Circle */
  38647. Circle = 1,
  38648. /** Square */
  38649. Square = 2,
  38650. /** Triangle */
  38651. Triangle = 3,
  38652. /** Options */
  38653. Options = 4,
  38654. /** Share */
  38655. Share = 5,
  38656. /** L1 */
  38657. L1 = 6,
  38658. /** R1 */
  38659. R1 = 7,
  38660. /** Left stick */
  38661. LeftStick = 8,
  38662. /** Right stick */
  38663. RightStick = 9
  38664. }
  38665. /** Defines values for DualShock DPad */
  38666. export enum DualShockDpad {
  38667. /** Up */
  38668. Up = 0,
  38669. /** Down */
  38670. Down = 1,
  38671. /** Left */
  38672. Left = 2,
  38673. /** Right */
  38674. Right = 3
  38675. }
  38676. /**
  38677. * Defines a DualShock gamepad
  38678. */
  38679. export class DualShockPad extends Gamepad {
  38680. private _leftTrigger;
  38681. private _rightTrigger;
  38682. private _onlefttriggerchanged;
  38683. private _onrighttriggerchanged;
  38684. private _onbuttondown;
  38685. private _onbuttonup;
  38686. private _ondpaddown;
  38687. private _ondpadup;
  38688. /** Observable raised when a button is pressed */
  38689. onButtonDownObservable: Observable<DualShockButton>;
  38690. /** Observable raised when a button is released */
  38691. onButtonUpObservable: Observable<DualShockButton>;
  38692. /** Observable raised when a pad is pressed */
  38693. onPadDownObservable: Observable<DualShockDpad>;
  38694. /** Observable raised when a pad is released */
  38695. onPadUpObservable: Observable<DualShockDpad>;
  38696. private _buttonCross;
  38697. private _buttonCircle;
  38698. private _buttonSquare;
  38699. private _buttonTriangle;
  38700. private _buttonShare;
  38701. private _buttonOptions;
  38702. private _buttonL1;
  38703. private _buttonR1;
  38704. private _buttonLeftStick;
  38705. private _buttonRightStick;
  38706. private _dPadUp;
  38707. private _dPadDown;
  38708. private _dPadLeft;
  38709. private _dPadRight;
  38710. /**
  38711. * Creates a new DualShock gamepad object
  38712. * @param id defines the id of this gamepad
  38713. * @param index defines its index
  38714. * @param gamepad defines the internal HTML gamepad object
  38715. */
  38716. constructor(id: string, index: number, gamepad: any);
  38717. /**
  38718. * Defines the callback to call when left trigger is pressed
  38719. * @param callback defines the callback to use
  38720. */
  38721. onlefttriggerchanged(callback: (value: number) => void): void;
  38722. /**
  38723. * Defines the callback to call when right trigger is pressed
  38724. * @param callback defines the callback to use
  38725. */
  38726. onrighttriggerchanged(callback: (value: number) => void): void;
  38727. /**
  38728. * Gets the left trigger value
  38729. */
  38730. /**
  38731. * Sets the left trigger value
  38732. */
  38733. leftTrigger: number;
  38734. /**
  38735. * Gets the right trigger value
  38736. */
  38737. /**
  38738. * Sets the right trigger value
  38739. */
  38740. rightTrigger: number;
  38741. /**
  38742. * Defines the callback to call when a button is pressed
  38743. * @param callback defines the callback to use
  38744. */
  38745. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38746. /**
  38747. * Defines the callback to call when a button is released
  38748. * @param callback defines the callback to use
  38749. */
  38750. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38751. /**
  38752. * Defines the callback to call when a pad is pressed
  38753. * @param callback defines the callback to use
  38754. */
  38755. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38756. /**
  38757. * Defines the callback to call when a pad is released
  38758. * @param callback defines the callback to use
  38759. */
  38760. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38761. private _setButtonValue;
  38762. private _setDPadValue;
  38763. /**
  38764. * Gets the value of the `Cross` button
  38765. */
  38766. /**
  38767. * Sets the value of the `Cross` button
  38768. */
  38769. buttonCross: number;
  38770. /**
  38771. * Gets the value of the `Circle` button
  38772. */
  38773. /**
  38774. * Sets the value of the `Circle` button
  38775. */
  38776. buttonCircle: number;
  38777. /**
  38778. * Gets the value of the `Square` button
  38779. */
  38780. /**
  38781. * Sets the value of the `Square` button
  38782. */
  38783. buttonSquare: number;
  38784. /**
  38785. * Gets the value of the `Triangle` button
  38786. */
  38787. /**
  38788. * Sets the value of the `Triangle` button
  38789. */
  38790. buttonTriangle: number;
  38791. /**
  38792. * Gets the value of the `Options` button
  38793. */
  38794. /**
  38795. * Sets the value of the `Options` button
  38796. */
  38797. buttonOptions: number;
  38798. /**
  38799. * Gets the value of the `Share` button
  38800. */
  38801. /**
  38802. * Sets the value of the `Share` button
  38803. */
  38804. buttonShare: number;
  38805. /**
  38806. * Gets the value of the `L1` button
  38807. */
  38808. /**
  38809. * Sets the value of the `L1` button
  38810. */
  38811. buttonL1: number;
  38812. /**
  38813. * Gets the value of the `R1` button
  38814. */
  38815. /**
  38816. * Sets the value of the `R1` button
  38817. */
  38818. buttonR1: number;
  38819. /**
  38820. * Gets the value of the Left joystick
  38821. */
  38822. /**
  38823. * Sets the value of the Left joystick
  38824. */
  38825. buttonLeftStick: number;
  38826. /**
  38827. * Gets the value of the Right joystick
  38828. */
  38829. /**
  38830. * Sets the value of the Right joystick
  38831. */
  38832. buttonRightStick: number;
  38833. /**
  38834. * Gets the value of D-pad up
  38835. */
  38836. /**
  38837. * Sets the value of D-pad up
  38838. */
  38839. dPadUp: number;
  38840. /**
  38841. * Gets the value of D-pad down
  38842. */
  38843. /**
  38844. * Sets the value of D-pad down
  38845. */
  38846. dPadDown: number;
  38847. /**
  38848. * Gets the value of D-pad left
  38849. */
  38850. /**
  38851. * Sets the value of D-pad left
  38852. */
  38853. dPadLeft: number;
  38854. /**
  38855. * Gets the value of D-pad right
  38856. */
  38857. /**
  38858. * Sets the value of D-pad right
  38859. */
  38860. dPadRight: number;
  38861. /**
  38862. * Force the gamepad to synchronize with device values
  38863. */
  38864. update(): void;
  38865. /**
  38866. * Disposes the gamepad
  38867. */
  38868. dispose(): void;
  38869. }
  38870. }
  38871. declare module BABYLON {
  38872. /**
  38873. * Manager for handling gamepads
  38874. */
  38875. export class GamepadManager {
  38876. private _scene?;
  38877. private _babylonGamepads;
  38878. private _oneGamepadConnected;
  38879. /** @hidden */
  38880. _isMonitoring: boolean;
  38881. private _gamepadEventSupported;
  38882. private _gamepadSupport;
  38883. /**
  38884. * observable to be triggered when the gamepad controller has been connected
  38885. */
  38886. onGamepadConnectedObservable: Observable<Gamepad>;
  38887. /**
  38888. * observable to be triggered when the gamepad controller has been disconnected
  38889. */
  38890. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38891. private _onGamepadConnectedEvent;
  38892. private _onGamepadDisconnectedEvent;
  38893. /**
  38894. * Initializes the gamepad manager
  38895. * @param _scene BabylonJS scene
  38896. */
  38897. constructor(_scene?: Scene | undefined);
  38898. /**
  38899. * The gamepads in the game pad manager
  38900. */
  38901. readonly gamepads: Gamepad[];
  38902. /**
  38903. * Get the gamepad controllers based on type
  38904. * @param type The type of gamepad controller
  38905. * @returns Nullable gamepad
  38906. */
  38907. getGamepadByType(type?: number): Nullable<Gamepad>;
  38908. /**
  38909. * Disposes the gamepad manager
  38910. */
  38911. dispose(): void;
  38912. private _addNewGamepad;
  38913. private _startMonitoringGamepads;
  38914. private _stopMonitoringGamepads;
  38915. /** @hidden */
  38916. _checkGamepadsStatus(): void;
  38917. private _updateGamepadObjects;
  38918. }
  38919. }
  38920. declare module BABYLON {
  38921. interface Scene {
  38922. /** @hidden */
  38923. _gamepadManager: Nullable<GamepadManager>;
  38924. /**
  38925. * Gets the gamepad manager associated with the scene
  38926. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38927. */
  38928. gamepadManager: GamepadManager;
  38929. }
  38930. /**
  38931. * Interface representing a free camera inputs manager
  38932. */
  38933. interface FreeCameraInputsManager {
  38934. /**
  38935. * Adds gamepad input support to the FreeCameraInputsManager.
  38936. * @returns the FreeCameraInputsManager
  38937. */
  38938. addGamepad(): FreeCameraInputsManager;
  38939. }
  38940. /**
  38941. * Interface representing an arc rotate camera inputs manager
  38942. */
  38943. interface ArcRotateCameraInputsManager {
  38944. /**
  38945. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38946. * @returns the camera inputs manager
  38947. */
  38948. addGamepad(): ArcRotateCameraInputsManager;
  38949. }
  38950. /**
  38951. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38952. */
  38953. export class GamepadSystemSceneComponent implements ISceneComponent {
  38954. /**
  38955. * The component name helpfull to identify the component in the list of scene components.
  38956. */
  38957. readonly name: string;
  38958. /**
  38959. * The scene the component belongs to.
  38960. */
  38961. scene: Scene;
  38962. /**
  38963. * Creates a new instance of the component for the given scene
  38964. * @param scene Defines the scene to register the component in
  38965. */
  38966. constructor(scene: Scene);
  38967. /**
  38968. * Registers the component in a given scene
  38969. */
  38970. register(): void;
  38971. /**
  38972. * Rebuilds the elements related to this component in case of
  38973. * context lost for instance.
  38974. */
  38975. rebuild(): void;
  38976. /**
  38977. * Disposes the component and the associated ressources
  38978. */
  38979. dispose(): void;
  38980. private _beforeCameraUpdate;
  38981. }
  38982. }
  38983. declare module BABYLON {
  38984. /**
  38985. * 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,
  38986. * which still works and will still be found in many Playgrounds.
  38987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38988. */
  38989. export class UniversalCamera extends TouchCamera {
  38990. /**
  38991. * Defines the gamepad rotation sensiblity.
  38992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38993. */
  38994. gamepadAngularSensibility: number;
  38995. /**
  38996. * Defines the gamepad move sensiblity.
  38997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38998. */
  38999. gamepadMoveSensibility: number;
  39000. /**
  39001. * 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,
  39002. * which still works and will still be found in many Playgrounds.
  39003. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39004. * @param name Define the name of the camera in the scene
  39005. * @param position Define the start position of the camera in the scene
  39006. * @param scene Define the scene the camera belongs to
  39007. */
  39008. constructor(name: string, position: Vector3, scene: Scene);
  39009. /**
  39010. * Gets the current object class name.
  39011. * @return the class name
  39012. */
  39013. getClassName(): string;
  39014. }
  39015. }
  39016. declare module BABYLON {
  39017. /**
  39018. * This represents a FPS type of camera. This is only here for back compat purpose.
  39019. * Please use the UniversalCamera instead as both are identical.
  39020. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39021. */
  39022. export class GamepadCamera extends UniversalCamera {
  39023. /**
  39024. * Instantiates a new Gamepad Camera
  39025. * This represents a FPS type of camera. This is only here for back compat purpose.
  39026. * Please use the UniversalCamera instead as both are identical.
  39027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39028. * @param name Define the name of the camera in the scene
  39029. * @param position Define the start position of the camera in the scene
  39030. * @param scene Define the scene the camera belongs to
  39031. */
  39032. constructor(name: string, position: Vector3, scene: Scene);
  39033. /**
  39034. * Gets the current object class name.
  39035. * @return the class name
  39036. */
  39037. getClassName(): string;
  39038. }
  39039. }
  39040. declare module BABYLON {
  39041. /** @hidden */
  39042. export var passPixelShader: {
  39043. name: string;
  39044. shader: string;
  39045. };
  39046. }
  39047. declare module BABYLON {
  39048. /** @hidden */
  39049. export var passCubePixelShader: {
  39050. name: string;
  39051. shader: string;
  39052. };
  39053. }
  39054. declare module BABYLON {
  39055. /**
  39056. * PassPostProcess which produces an output the same as it's input
  39057. */
  39058. export class PassPostProcess extends PostProcess {
  39059. /**
  39060. * Creates the PassPostProcess
  39061. * @param name The name of the effect.
  39062. * @param options The required width/height ratio to downsize to before computing the render pass.
  39063. * @param camera The camera to apply the render pass to.
  39064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39065. * @param engine The engine which the post process will be applied. (default: current engine)
  39066. * @param reusable If the post process can be reused on the same frame. (default: false)
  39067. * @param textureType The type of texture to be used when performing the post processing.
  39068. * @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)
  39069. */
  39070. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39071. }
  39072. /**
  39073. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39074. */
  39075. export class PassCubePostProcess extends PostProcess {
  39076. private _face;
  39077. /**
  39078. * Gets or sets the cube face to display.
  39079. * * 0 is +X
  39080. * * 1 is -X
  39081. * * 2 is +Y
  39082. * * 3 is -Y
  39083. * * 4 is +Z
  39084. * * 5 is -Z
  39085. */
  39086. face: number;
  39087. /**
  39088. * Creates the PassCubePostProcess
  39089. * @param name The name of the effect.
  39090. * @param options The required width/height ratio to downsize to before computing the render pass.
  39091. * @param camera The camera to apply the render pass to.
  39092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39093. * @param engine The engine which the post process will be applied. (default: current engine)
  39094. * @param reusable If the post process can be reused on the same frame. (default: false)
  39095. * @param textureType The type of texture to be used when performing the post processing.
  39096. * @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)
  39097. */
  39098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39099. }
  39100. }
  39101. declare module BABYLON {
  39102. /** @hidden */
  39103. export var anaglyphPixelShader: {
  39104. name: string;
  39105. shader: string;
  39106. };
  39107. }
  39108. declare module BABYLON {
  39109. /**
  39110. * Postprocess used to generate anaglyphic rendering
  39111. */
  39112. export class AnaglyphPostProcess extends PostProcess {
  39113. private _passedProcess;
  39114. /**
  39115. * Creates a new AnaglyphPostProcess
  39116. * @param name defines postprocess name
  39117. * @param options defines creation options or target ratio scale
  39118. * @param rigCameras defines cameras using this postprocess
  39119. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39120. * @param engine defines hosting engine
  39121. * @param reusable defines if the postprocess will be reused multiple times per frame
  39122. */
  39123. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39124. }
  39125. }
  39126. declare module BABYLON {
  39127. /**
  39128. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39129. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39130. */
  39131. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39132. /**
  39133. * Creates a new AnaglyphArcRotateCamera
  39134. * @param name defines camera name
  39135. * @param alpha defines alpha angle (in radians)
  39136. * @param beta defines beta angle (in radians)
  39137. * @param radius defines radius
  39138. * @param target defines camera target
  39139. * @param interaxialDistance defines distance between each color axis
  39140. * @param scene defines the hosting scene
  39141. */
  39142. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39143. /**
  39144. * Gets camera class name
  39145. * @returns AnaglyphArcRotateCamera
  39146. */
  39147. getClassName(): string;
  39148. }
  39149. }
  39150. declare module BABYLON {
  39151. /**
  39152. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39154. */
  39155. export class AnaglyphFreeCamera extends FreeCamera {
  39156. /**
  39157. * Creates a new AnaglyphFreeCamera
  39158. * @param name defines camera name
  39159. * @param position defines initial position
  39160. * @param interaxialDistance defines distance between each color axis
  39161. * @param scene defines the hosting scene
  39162. */
  39163. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39164. /**
  39165. * Gets camera class name
  39166. * @returns AnaglyphFreeCamera
  39167. */
  39168. getClassName(): string;
  39169. }
  39170. }
  39171. declare module BABYLON {
  39172. /**
  39173. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39174. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39175. */
  39176. export class AnaglyphGamepadCamera extends GamepadCamera {
  39177. /**
  39178. * Creates a new AnaglyphGamepadCamera
  39179. * @param name defines camera name
  39180. * @param position defines initial position
  39181. * @param interaxialDistance defines distance between each color axis
  39182. * @param scene defines the hosting scene
  39183. */
  39184. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39185. /**
  39186. * Gets camera class name
  39187. * @returns AnaglyphGamepadCamera
  39188. */
  39189. getClassName(): string;
  39190. }
  39191. }
  39192. declare module BABYLON {
  39193. /**
  39194. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39196. */
  39197. export class AnaglyphUniversalCamera extends UniversalCamera {
  39198. /**
  39199. * Creates a new AnaglyphUniversalCamera
  39200. * @param name defines camera name
  39201. * @param position defines initial position
  39202. * @param interaxialDistance defines distance between each color axis
  39203. * @param scene defines the hosting scene
  39204. */
  39205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39206. /**
  39207. * Gets camera class name
  39208. * @returns AnaglyphUniversalCamera
  39209. */
  39210. getClassName(): string;
  39211. }
  39212. }
  39213. declare module BABYLON {
  39214. /** @hidden */
  39215. export var stereoscopicInterlacePixelShader: {
  39216. name: string;
  39217. shader: string;
  39218. };
  39219. }
  39220. declare module BABYLON {
  39221. /**
  39222. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39223. */
  39224. export class StereoscopicInterlacePostProcess extends PostProcess {
  39225. private _stepSize;
  39226. private _passedProcess;
  39227. /**
  39228. * Initializes a StereoscopicInterlacePostProcess
  39229. * @param name The name of the effect.
  39230. * @param rigCameras The rig cameras to be appled to the post process
  39231. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39233. * @param engine The engine which the post process will be applied. (default: current engine)
  39234. * @param reusable If the post process can be reused on the same frame. (default: false)
  39235. */
  39236. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39237. }
  39238. }
  39239. declare module BABYLON {
  39240. /**
  39241. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39242. * @see http://doc.babylonjs.com/features/cameras
  39243. */
  39244. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39245. /**
  39246. * Creates a new StereoscopicArcRotateCamera
  39247. * @param name defines camera name
  39248. * @param alpha defines alpha angle (in radians)
  39249. * @param beta defines beta angle (in radians)
  39250. * @param radius defines radius
  39251. * @param target defines camera target
  39252. * @param interaxialDistance defines distance between each color axis
  39253. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39254. * @param scene defines the hosting scene
  39255. */
  39256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39257. /**
  39258. * Gets camera class name
  39259. * @returns StereoscopicArcRotateCamera
  39260. */
  39261. getClassName(): string;
  39262. }
  39263. }
  39264. declare module BABYLON {
  39265. /**
  39266. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39267. * @see http://doc.babylonjs.com/features/cameras
  39268. */
  39269. export class StereoscopicFreeCamera extends FreeCamera {
  39270. /**
  39271. * Creates a new StereoscopicFreeCamera
  39272. * @param name defines camera name
  39273. * @param position defines initial position
  39274. * @param interaxialDistance defines distance between each color axis
  39275. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39276. * @param scene defines the hosting scene
  39277. */
  39278. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39279. /**
  39280. * Gets camera class name
  39281. * @returns StereoscopicFreeCamera
  39282. */
  39283. getClassName(): string;
  39284. }
  39285. }
  39286. declare module BABYLON {
  39287. /**
  39288. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39289. * @see http://doc.babylonjs.com/features/cameras
  39290. */
  39291. export class StereoscopicGamepadCamera extends GamepadCamera {
  39292. /**
  39293. * Creates a new StereoscopicGamepadCamera
  39294. * @param name defines camera name
  39295. * @param position defines initial position
  39296. * @param interaxialDistance defines distance between each color axis
  39297. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39298. * @param scene defines the hosting scene
  39299. */
  39300. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39301. /**
  39302. * Gets camera class name
  39303. * @returns StereoscopicGamepadCamera
  39304. */
  39305. getClassName(): string;
  39306. }
  39307. }
  39308. declare module BABYLON {
  39309. /**
  39310. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39311. * @see http://doc.babylonjs.com/features/cameras
  39312. */
  39313. export class StereoscopicUniversalCamera extends UniversalCamera {
  39314. /**
  39315. * Creates a new StereoscopicUniversalCamera
  39316. * @param name defines camera name
  39317. * @param position defines initial position
  39318. * @param interaxialDistance defines distance between each color axis
  39319. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39320. * @param scene defines the hosting scene
  39321. */
  39322. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39323. /**
  39324. * Gets camera class name
  39325. * @returns StereoscopicUniversalCamera
  39326. */
  39327. getClassName(): string;
  39328. }
  39329. }
  39330. declare module BABYLON {
  39331. /**
  39332. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39333. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39334. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39335. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39336. */
  39337. export class VirtualJoysticksCamera extends FreeCamera {
  39338. /**
  39339. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39340. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39341. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39342. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39343. * @param name Define the name of the camera in the scene
  39344. * @param position Define the start position of the camera in the scene
  39345. * @param scene Define the scene the camera belongs to
  39346. */
  39347. constructor(name: string, position: Vector3, scene: Scene);
  39348. /**
  39349. * Gets the current object class name.
  39350. * @return the class name
  39351. */
  39352. getClassName(): string;
  39353. }
  39354. }
  39355. declare module BABYLON {
  39356. /**
  39357. * This represents all the required metrics to create a VR camera.
  39358. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39359. */
  39360. export class VRCameraMetrics {
  39361. /**
  39362. * Define the horizontal resolution off the screen.
  39363. */
  39364. hResolution: number;
  39365. /**
  39366. * Define the vertical resolution off the screen.
  39367. */
  39368. vResolution: number;
  39369. /**
  39370. * Define the horizontal screen size.
  39371. */
  39372. hScreenSize: number;
  39373. /**
  39374. * Define the vertical screen size.
  39375. */
  39376. vScreenSize: number;
  39377. /**
  39378. * Define the vertical screen center position.
  39379. */
  39380. vScreenCenter: number;
  39381. /**
  39382. * Define the distance of the eyes to the screen.
  39383. */
  39384. eyeToScreenDistance: number;
  39385. /**
  39386. * Define the distance between both lenses
  39387. */
  39388. lensSeparationDistance: number;
  39389. /**
  39390. * Define the distance between both viewer's eyes.
  39391. */
  39392. interpupillaryDistance: number;
  39393. /**
  39394. * Define the distortion factor of the VR postprocess.
  39395. * Please, touch with care.
  39396. */
  39397. distortionK: number[];
  39398. /**
  39399. * Define the chromatic aberration correction factors for the VR post process.
  39400. */
  39401. chromaAbCorrection: number[];
  39402. /**
  39403. * Define the scale factor of the post process.
  39404. * The smaller the better but the slower.
  39405. */
  39406. postProcessScaleFactor: number;
  39407. /**
  39408. * Define an offset for the lens center.
  39409. */
  39410. lensCenterOffset: number;
  39411. /**
  39412. * Define if the current vr camera should compensate the distortion of the lense or not.
  39413. */
  39414. compensateDistortion: boolean;
  39415. /**
  39416. * Defines if multiview should be enabled when rendering (Default: false)
  39417. */
  39418. multiviewEnabled: boolean;
  39419. /**
  39420. * Gets the rendering aspect ratio based on the provided resolutions.
  39421. */
  39422. readonly aspectRatio: number;
  39423. /**
  39424. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39425. */
  39426. readonly aspectRatioFov: number;
  39427. /**
  39428. * @hidden
  39429. */
  39430. readonly leftHMatrix: Matrix;
  39431. /**
  39432. * @hidden
  39433. */
  39434. readonly rightHMatrix: Matrix;
  39435. /**
  39436. * @hidden
  39437. */
  39438. readonly leftPreViewMatrix: Matrix;
  39439. /**
  39440. * @hidden
  39441. */
  39442. readonly rightPreViewMatrix: Matrix;
  39443. /**
  39444. * Get the default VRMetrics based on the most generic setup.
  39445. * @returns the default vr metrics
  39446. */
  39447. static GetDefault(): VRCameraMetrics;
  39448. }
  39449. }
  39450. declare module BABYLON {
  39451. /** @hidden */
  39452. export var vrDistortionCorrectionPixelShader: {
  39453. name: string;
  39454. shader: string;
  39455. };
  39456. }
  39457. declare module BABYLON {
  39458. /**
  39459. * VRDistortionCorrectionPostProcess used for mobile VR
  39460. */
  39461. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39462. private _isRightEye;
  39463. private _distortionFactors;
  39464. private _postProcessScaleFactor;
  39465. private _lensCenterOffset;
  39466. private _scaleIn;
  39467. private _scaleFactor;
  39468. private _lensCenter;
  39469. /**
  39470. * Initializes the VRDistortionCorrectionPostProcess
  39471. * @param name The name of the effect.
  39472. * @param camera The camera to apply the render pass to.
  39473. * @param isRightEye If this is for the right eye distortion
  39474. * @param vrMetrics All the required metrics for the VR camera
  39475. */
  39476. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39477. }
  39478. }
  39479. declare module BABYLON {
  39480. /**
  39481. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39482. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39483. */
  39484. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39485. /**
  39486. * Creates a new VRDeviceOrientationArcRotateCamera
  39487. * @param name defines camera name
  39488. * @param alpha defines the camera rotation along the logitudinal axis
  39489. * @param beta defines the camera rotation along the latitudinal axis
  39490. * @param radius defines the camera distance from its target
  39491. * @param target defines the camera target
  39492. * @param scene defines the scene the camera belongs to
  39493. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39494. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39495. */
  39496. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39497. /**
  39498. * Gets camera class name
  39499. * @returns VRDeviceOrientationArcRotateCamera
  39500. */
  39501. getClassName(): string;
  39502. }
  39503. }
  39504. declare module BABYLON {
  39505. /**
  39506. * Camera used to simulate VR rendering (based on FreeCamera)
  39507. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39508. */
  39509. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39510. /**
  39511. * Creates a new VRDeviceOrientationFreeCamera
  39512. * @param name defines camera name
  39513. * @param position defines the start position of the camera
  39514. * @param scene defines the scene the camera belongs to
  39515. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39516. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39517. */
  39518. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39519. /**
  39520. * Gets camera class name
  39521. * @returns VRDeviceOrientationFreeCamera
  39522. */
  39523. getClassName(): string;
  39524. }
  39525. }
  39526. declare module BABYLON {
  39527. /**
  39528. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39529. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39530. */
  39531. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39532. /**
  39533. * Creates a new VRDeviceOrientationGamepadCamera
  39534. * @param name defines camera name
  39535. * @param position defines the start position of the camera
  39536. * @param scene defines the scene the camera belongs to
  39537. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39538. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39539. */
  39540. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39541. /**
  39542. * Gets camera class name
  39543. * @returns VRDeviceOrientationGamepadCamera
  39544. */
  39545. getClassName(): string;
  39546. }
  39547. }
  39548. declare module BABYLON {
  39549. /**
  39550. * Base class of materials working in push mode in babylon JS
  39551. * @hidden
  39552. */
  39553. export class PushMaterial extends Material {
  39554. protected _activeEffect: Effect;
  39555. protected _normalMatrix: Matrix;
  39556. /**
  39557. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39558. * This means that the material can keep using a previous shader while a new one is being compiled.
  39559. * This is mostly used when shader parallel compilation is supported (true by default)
  39560. */
  39561. allowShaderHotSwapping: boolean;
  39562. constructor(name: string, scene: Scene);
  39563. getEffect(): Effect;
  39564. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39565. /**
  39566. * Binds the given world matrix to the active effect
  39567. *
  39568. * @param world the matrix to bind
  39569. */
  39570. bindOnlyWorldMatrix(world: Matrix): void;
  39571. /**
  39572. * Binds the given normal matrix to the active effect
  39573. *
  39574. * @param normalMatrix the matrix to bind
  39575. */
  39576. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39577. bind(world: Matrix, mesh?: Mesh): void;
  39578. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39579. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39580. }
  39581. }
  39582. declare module BABYLON {
  39583. /**
  39584. * This groups all the flags used to control the materials channel.
  39585. */
  39586. export class MaterialFlags {
  39587. private static _DiffuseTextureEnabled;
  39588. /**
  39589. * Are diffuse textures enabled in the application.
  39590. */
  39591. static DiffuseTextureEnabled: boolean;
  39592. private static _AmbientTextureEnabled;
  39593. /**
  39594. * Are ambient textures enabled in the application.
  39595. */
  39596. static AmbientTextureEnabled: boolean;
  39597. private static _OpacityTextureEnabled;
  39598. /**
  39599. * Are opacity textures enabled in the application.
  39600. */
  39601. static OpacityTextureEnabled: boolean;
  39602. private static _ReflectionTextureEnabled;
  39603. /**
  39604. * Are reflection textures enabled in the application.
  39605. */
  39606. static ReflectionTextureEnabled: boolean;
  39607. private static _EmissiveTextureEnabled;
  39608. /**
  39609. * Are emissive textures enabled in the application.
  39610. */
  39611. static EmissiveTextureEnabled: boolean;
  39612. private static _SpecularTextureEnabled;
  39613. /**
  39614. * Are specular textures enabled in the application.
  39615. */
  39616. static SpecularTextureEnabled: boolean;
  39617. private static _BumpTextureEnabled;
  39618. /**
  39619. * Are bump textures enabled in the application.
  39620. */
  39621. static BumpTextureEnabled: boolean;
  39622. private static _LightmapTextureEnabled;
  39623. /**
  39624. * Are lightmap textures enabled in the application.
  39625. */
  39626. static LightmapTextureEnabled: boolean;
  39627. private static _RefractionTextureEnabled;
  39628. /**
  39629. * Are refraction textures enabled in the application.
  39630. */
  39631. static RefractionTextureEnabled: boolean;
  39632. private static _ColorGradingTextureEnabled;
  39633. /**
  39634. * Are color grading textures enabled in the application.
  39635. */
  39636. static ColorGradingTextureEnabled: boolean;
  39637. private static _FresnelEnabled;
  39638. /**
  39639. * Are fresnels enabled in the application.
  39640. */
  39641. static FresnelEnabled: boolean;
  39642. private static _ClearCoatTextureEnabled;
  39643. /**
  39644. * Are clear coat textures enabled in the application.
  39645. */
  39646. static ClearCoatTextureEnabled: boolean;
  39647. private static _ClearCoatBumpTextureEnabled;
  39648. /**
  39649. * Are clear coat bump textures enabled in the application.
  39650. */
  39651. static ClearCoatBumpTextureEnabled: boolean;
  39652. private static _ClearCoatTintTextureEnabled;
  39653. /**
  39654. * Are clear coat tint textures enabled in the application.
  39655. */
  39656. static ClearCoatTintTextureEnabled: boolean;
  39657. private static _SheenTextureEnabled;
  39658. /**
  39659. * Are sheen textures enabled in the application.
  39660. */
  39661. static SheenTextureEnabled: boolean;
  39662. private static _AnisotropicTextureEnabled;
  39663. /**
  39664. * Are anisotropic textures enabled in the application.
  39665. */
  39666. static AnisotropicTextureEnabled: boolean;
  39667. private static _ThicknessTextureEnabled;
  39668. /**
  39669. * Are thickness textures enabled in the application.
  39670. */
  39671. static ThicknessTextureEnabled: boolean;
  39672. }
  39673. }
  39674. declare module BABYLON {
  39675. /** @hidden */
  39676. export var defaultFragmentDeclaration: {
  39677. name: string;
  39678. shader: string;
  39679. };
  39680. }
  39681. declare module BABYLON {
  39682. /** @hidden */
  39683. export var defaultUboDeclaration: {
  39684. name: string;
  39685. shader: string;
  39686. };
  39687. }
  39688. declare module BABYLON {
  39689. /** @hidden */
  39690. export var lightFragmentDeclaration: {
  39691. name: string;
  39692. shader: string;
  39693. };
  39694. }
  39695. declare module BABYLON {
  39696. /** @hidden */
  39697. export var lightUboDeclaration: {
  39698. name: string;
  39699. shader: string;
  39700. };
  39701. }
  39702. declare module BABYLON {
  39703. /** @hidden */
  39704. export var lightsFragmentFunctions: {
  39705. name: string;
  39706. shader: string;
  39707. };
  39708. }
  39709. declare module BABYLON {
  39710. /** @hidden */
  39711. export var shadowsFragmentFunctions: {
  39712. name: string;
  39713. shader: string;
  39714. };
  39715. }
  39716. declare module BABYLON {
  39717. /** @hidden */
  39718. export var fresnelFunction: {
  39719. name: string;
  39720. shader: string;
  39721. };
  39722. }
  39723. declare module BABYLON {
  39724. /** @hidden */
  39725. export var reflectionFunction: {
  39726. name: string;
  39727. shader: string;
  39728. };
  39729. }
  39730. declare module BABYLON {
  39731. /** @hidden */
  39732. export var bumpFragmentFunctions: {
  39733. name: string;
  39734. shader: string;
  39735. };
  39736. }
  39737. declare module BABYLON {
  39738. /** @hidden */
  39739. export var logDepthDeclaration: {
  39740. name: string;
  39741. shader: string;
  39742. };
  39743. }
  39744. declare module BABYLON {
  39745. /** @hidden */
  39746. export var bumpFragment: {
  39747. name: string;
  39748. shader: string;
  39749. };
  39750. }
  39751. declare module BABYLON {
  39752. /** @hidden */
  39753. export var depthPrePass: {
  39754. name: string;
  39755. shader: string;
  39756. };
  39757. }
  39758. declare module BABYLON {
  39759. /** @hidden */
  39760. export var lightFragment: {
  39761. name: string;
  39762. shader: string;
  39763. };
  39764. }
  39765. declare module BABYLON {
  39766. /** @hidden */
  39767. export var logDepthFragment: {
  39768. name: string;
  39769. shader: string;
  39770. };
  39771. }
  39772. declare module BABYLON {
  39773. /** @hidden */
  39774. export var defaultPixelShader: {
  39775. name: string;
  39776. shader: string;
  39777. };
  39778. }
  39779. declare module BABYLON {
  39780. /** @hidden */
  39781. export var defaultVertexDeclaration: {
  39782. name: string;
  39783. shader: string;
  39784. };
  39785. }
  39786. declare module BABYLON {
  39787. /** @hidden */
  39788. export var bumpVertexDeclaration: {
  39789. name: string;
  39790. shader: string;
  39791. };
  39792. }
  39793. declare module BABYLON {
  39794. /** @hidden */
  39795. export var bumpVertex: {
  39796. name: string;
  39797. shader: string;
  39798. };
  39799. }
  39800. declare module BABYLON {
  39801. /** @hidden */
  39802. export var fogVertex: {
  39803. name: string;
  39804. shader: string;
  39805. };
  39806. }
  39807. declare module BABYLON {
  39808. /** @hidden */
  39809. export var shadowsVertex: {
  39810. name: string;
  39811. shader: string;
  39812. };
  39813. }
  39814. declare module BABYLON {
  39815. /** @hidden */
  39816. export var pointCloudVertex: {
  39817. name: string;
  39818. shader: string;
  39819. };
  39820. }
  39821. declare module BABYLON {
  39822. /** @hidden */
  39823. export var logDepthVertex: {
  39824. name: string;
  39825. shader: string;
  39826. };
  39827. }
  39828. declare module BABYLON {
  39829. /** @hidden */
  39830. export var defaultVertexShader: {
  39831. name: string;
  39832. shader: string;
  39833. };
  39834. }
  39835. declare module BABYLON {
  39836. /** @hidden */
  39837. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39838. MAINUV1: boolean;
  39839. MAINUV2: boolean;
  39840. DIFFUSE: boolean;
  39841. DIFFUSEDIRECTUV: number;
  39842. AMBIENT: boolean;
  39843. AMBIENTDIRECTUV: number;
  39844. OPACITY: boolean;
  39845. OPACITYDIRECTUV: number;
  39846. OPACITYRGB: boolean;
  39847. REFLECTION: boolean;
  39848. EMISSIVE: boolean;
  39849. EMISSIVEDIRECTUV: number;
  39850. SPECULAR: boolean;
  39851. SPECULARDIRECTUV: number;
  39852. BUMP: boolean;
  39853. BUMPDIRECTUV: number;
  39854. PARALLAX: boolean;
  39855. PARALLAXOCCLUSION: boolean;
  39856. SPECULAROVERALPHA: boolean;
  39857. CLIPPLANE: boolean;
  39858. CLIPPLANE2: boolean;
  39859. CLIPPLANE3: boolean;
  39860. CLIPPLANE4: boolean;
  39861. ALPHATEST: boolean;
  39862. DEPTHPREPASS: boolean;
  39863. ALPHAFROMDIFFUSE: boolean;
  39864. POINTSIZE: boolean;
  39865. FOG: boolean;
  39866. SPECULARTERM: boolean;
  39867. DIFFUSEFRESNEL: boolean;
  39868. OPACITYFRESNEL: boolean;
  39869. REFLECTIONFRESNEL: boolean;
  39870. REFRACTIONFRESNEL: boolean;
  39871. EMISSIVEFRESNEL: boolean;
  39872. FRESNEL: boolean;
  39873. NORMAL: boolean;
  39874. UV1: boolean;
  39875. UV2: boolean;
  39876. VERTEXCOLOR: boolean;
  39877. VERTEXALPHA: boolean;
  39878. NUM_BONE_INFLUENCERS: number;
  39879. BonesPerMesh: number;
  39880. BONETEXTURE: boolean;
  39881. INSTANCES: boolean;
  39882. GLOSSINESS: boolean;
  39883. ROUGHNESS: boolean;
  39884. EMISSIVEASILLUMINATION: boolean;
  39885. LINKEMISSIVEWITHDIFFUSE: boolean;
  39886. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39887. LIGHTMAP: boolean;
  39888. LIGHTMAPDIRECTUV: number;
  39889. OBJECTSPACE_NORMALMAP: boolean;
  39890. USELIGHTMAPASSHADOWMAP: boolean;
  39891. REFLECTIONMAP_3D: boolean;
  39892. REFLECTIONMAP_SPHERICAL: boolean;
  39893. REFLECTIONMAP_PLANAR: boolean;
  39894. REFLECTIONMAP_CUBIC: boolean;
  39895. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39896. REFLECTIONMAP_PROJECTION: boolean;
  39897. REFLECTIONMAP_SKYBOX: boolean;
  39898. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39899. REFLECTIONMAP_EXPLICIT: boolean;
  39900. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39901. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39902. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39903. INVERTCUBICMAP: boolean;
  39904. LOGARITHMICDEPTH: boolean;
  39905. REFRACTION: boolean;
  39906. REFRACTIONMAP_3D: boolean;
  39907. REFLECTIONOVERALPHA: boolean;
  39908. TWOSIDEDLIGHTING: boolean;
  39909. SHADOWFLOAT: boolean;
  39910. MORPHTARGETS: boolean;
  39911. MORPHTARGETS_NORMAL: boolean;
  39912. MORPHTARGETS_TANGENT: boolean;
  39913. MORPHTARGETS_UV: boolean;
  39914. NUM_MORPH_INFLUENCERS: number;
  39915. NONUNIFORMSCALING: boolean;
  39916. PREMULTIPLYALPHA: boolean;
  39917. IMAGEPROCESSING: boolean;
  39918. VIGNETTE: boolean;
  39919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39920. VIGNETTEBLENDMODEOPAQUE: boolean;
  39921. TONEMAPPING: boolean;
  39922. TONEMAPPING_ACES: boolean;
  39923. CONTRAST: boolean;
  39924. COLORCURVES: boolean;
  39925. COLORGRADING: boolean;
  39926. COLORGRADING3D: boolean;
  39927. SAMPLER3DGREENDEPTH: boolean;
  39928. SAMPLER3DBGRMAP: boolean;
  39929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39930. MULTIVIEW: boolean;
  39931. /**
  39932. * If the reflection texture on this material is in linear color space
  39933. * @hidden
  39934. */
  39935. IS_REFLECTION_LINEAR: boolean;
  39936. /**
  39937. * If the refraction texture on this material is in linear color space
  39938. * @hidden
  39939. */
  39940. IS_REFRACTION_LINEAR: boolean;
  39941. EXPOSURE: boolean;
  39942. constructor();
  39943. setReflectionMode(modeToEnable: string): void;
  39944. }
  39945. /**
  39946. * This is the default material used in Babylon. It is the best trade off between quality
  39947. * and performances.
  39948. * @see http://doc.babylonjs.com/babylon101/materials
  39949. */
  39950. export class StandardMaterial extends PushMaterial {
  39951. private _diffuseTexture;
  39952. /**
  39953. * The basic texture of the material as viewed under a light.
  39954. */
  39955. diffuseTexture: Nullable<BaseTexture>;
  39956. private _ambientTexture;
  39957. /**
  39958. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39959. */
  39960. ambientTexture: Nullable<BaseTexture>;
  39961. private _opacityTexture;
  39962. /**
  39963. * Define the transparency of the material from a texture.
  39964. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39965. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39966. */
  39967. opacityTexture: Nullable<BaseTexture>;
  39968. private _reflectionTexture;
  39969. /**
  39970. * Define the texture used to display the reflection.
  39971. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39972. */
  39973. reflectionTexture: Nullable<BaseTexture>;
  39974. private _emissiveTexture;
  39975. /**
  39976. * Define texture of the material as if self lit.
  39977. * This will be mixed in the final result even in the absence of light.
  39978. */
  39979. emissiveTexture: Nullable<BaseTexture>;
  39980. private _specularTexture;
  39981. /**
  39982. * Define how the color and intensity of the highlight given by the light in the material.
  39983. */
  39984. specularTexture: Nullable<BaseTexture>;
  39985. private _bumpTexture;
  39986. /**
  39987. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39988. * 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.
  39989. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39990. */
  39991. bumpTexture: Nullable<BaseTexture>;
  39992. private _lightmapTexture;
  39993. /**
  39994. * Complex lighting can be computationally expensive to compute at runtime.
  39995. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39996. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39997. */
  39998. lightmapTexture: Nullable<BaseTexture>;
  39999. private _refractionTexture;
  40000. /**
  40001. * Define the texture used to display the refraction.
  40002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40003. */
  40004. refractionTexture: Nullable<BaseTexture>;
  40005. /**
  40006. * The color of the material lit by the environmental background lighting.
  40007. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40008. */
  40009. ambientColor: Color3;
  40010. /**
  40011. * The basic color of the material as viewed under a light.
  40012. */
  40013. diffuseColor: Color3;
  40014. /**
  40015. * Define how the color and intensity of the highlight given by the light in the material.
  40016. */
  40017. specularColor: Color3;
  40018. /**
  40019. * Define the color of the material as if self lit.
  40020. * This will be mixed in the final result even in the absence of light.
  40021. */
  40022. emissiveColor: Color3;
  40023. /**
  40024. * Defines how sharp are the highlights in the material.
  40025. * The bigger the value the sharper giving a more glossy feeling to the result.
  40026. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40027. */
  40028. specularPower: number;
  40029. private _useAlphaFromDiffuseTexture;
  40030. /**
  40031. * Does the transparency come from the diffuse texture alpha channel.
  40032. */
  40033. useAlphaFromDiffuseTexture: boolean;
  40034. private _useEmissiveAsIllumination;
  40035. /**
  40036. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40037. */
  40038. useEmissiveAsIllumination: boolean;
  40039. private _linkEmissiveWithDiffuse;
  40040. /**
  40041. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40042. * the emissive level when the final color is close to one.
  40043. */
  40044. linkEmissiveWithDiffuse: boolean;
  40045. private _useSpecularOverAlpha;
  40046. /**
  40047. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40048. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40049. */
  40050. useSpecularOverAlpha: boolean;
  40051. private _useReflectionOverAlpha;
  40052. /**
  40053. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40054. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40055. */
  40056. useReflectionOverAlpha: boolean;
  40057. private _disableLighting;
  40058. /**
  40059. * Does lights from the scene impacts this material.
  40060. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40061. */
  40062. disableLighting: boolean;
  40063. private _useObjectSpaceNormalMap;
  40064. /**
  40065. * Allows using an object space normal map (instead of tangent space).
  40066. */
  40067. useObjectSpaceNormalMap: boolean;
  40068. private _useParallax;
  40069. /**
  40070. * Is parallax enabled or not.
  40071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40072. */
  40073. useParallax: boolean;
  40074. private _useParallaxOcclusion;
  40075. /**
  40076. * Is parallax occlusion enabled or not.
  40077. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40078. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40079. */
  40080. useParallaxOcclusion: boolean;
  40081. /**
  40082. * 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.
  40083. */
  40084. parallaxScaleBias: number;
  40085. private _roughness;
  40086. /**
  40087. * Helps to define how blurry the reflections should appears in the material.
  40088. */
  40089. roughness: number;
  40090. /**
  40091. * In case of refraction, define the value of the index of refraction.
  40092. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40093. */
  40094. indexOfRefraction: number;
  40095. /**
  40096. * Invert the refraction texture alongside the y axis.
  40097. * It can be useful with procedural textures or probe for instance.
  40098. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40099. */
  40100. invertRefractionY: boolean;
  40101. /**
  40102. * Defines the alpha limits in alpha test mode.
  40103. */
  40104. alphaCutOff: number;
  40105. private _useLightmapAsShadowmap;
  40106. /**
  40107. * In case of light mapping, define whether the map contains light or shadow informations.
  40108. */
  40109. useLightmapAsShadowmap: boolean;
  40110. private _diffuseFresnelParameters;
  40111. /**
  40112. * Define the diffuse fresnel parameters of the material.
  40113. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40114. */
  40115. diffuseFresnelParameters: FresnelParameters;
  40116. private _opacityFresnelParameters;
  40117. /**
  40118. * Define the opacity fresnel parameters of the material.
  40119. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40120. */
  40121. opacityFresnelParameters: FresnelParameters;
  40122. private _reflectionFresnelParameters;
  40123. /**
  40124. * Define the reflection fresnel parameters of the material.
  40125. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40126. */
  40127. reflectionFresnelParameters: FresnelParameters;
  40128. private _refractionFresnelParameters;
  40129. /**
  40130. * Define the refraction fresnel parameters of the material.
  40131. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40132. */
  40133. refractionFresnelParameters: FresnelParameters;
  40134. private _emissiveFresnelParameters;
  40135. /**
  40136. * Define the emissive fresnel parameters of the material.
  40137. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40138. */
  40139. emissiveFresnelParameters: FresnelParameters;
  40140. private _useReflectionFresnelFromSpecular;
  40141. /**
  40142. * If true automatically deducts the fresnels values from the material specularity.
  40143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40144. */
  40145. useReflectionFresnelFromSpecular: boolean;
  40146. private _useGlossinessFromSpecularMapAlpha;
  40147. /**
  40148. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40149. */
  40150. useGlossinessFromSpecularMapAlpha: boolean;
  40151. private _maxSimultaneousLights;
  40152. /**
  40153. * Defines the maximum number of lights that can be used in the material
  40154. */
  40155. maxSimultaneousLights: number;
  40156. private _invertNormalMapX;
  40157. /**
  40158. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40159. */
  40160. invertNormalMapX: boolean;
  40161. private _invertNormalMapY;
  40162. /**
  40163. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40164. */
  40165. invertNormalMapY: boolean;
  40166. private _twoSidedLighting;
  40167. /**
  40168. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40169. */
  40170. twoSidedLighting: boolean;
  40171. /**
  40172. * Default configuration related to image processing available in the standard Material.
  40173. */
  40174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40175. /**
  40176. * Gets the image processing configuration used either in this material.
  40177. */
  40178. /**
  40179. * Sets the Default image processing configuration used either in the this material.
  40180. *
  40181. * If sets to null, the scene one is in use.
  40182. */
  40183. imageProcessingConfiguration: ImageProcessingConfiguration;
  40184. /**
  40185. * Keep track of the image processing observer to allow dispose and replace.
  40186. */
  40187. private _imageProcessingObserver;
  40188. /**
  40189. * Attaches a new image processing configuration to the Standard Material.
  40190. * @param configuration
  40191. */
  40192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40193. /**
  40194. * Gets wether the color curves effect is enabled.
  40195. */
  40196. /**
  40197. * Sets wether the color curves effect is enabled.
  40198. */
  40199. cameraColorCurvesEnabled: boolean;
  40200. /**
  40201. * Gets wether the color grading effect is enabled.
  40202. */
  40203. /**
  40204. * Gets wether the color grading effect is enabled.
  40205. */
  40206. cameraColorGradingEnabled: boolean;
  40207. /**
  40208. * Gets wether tonemapping is enabled or not.
  40209. */
  40210. /**
  40211. * Sets wether tonemapping is enabled or not
  40212. */
  40213. cameraToneMappingEnabled: boolean;
  40214. /**
  40215. * The camera exposure used on this material.
  40216. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40217. * This corresponds to a photographic exposure.
  40218. */
  40219. /**
  40220. * The camera exposure used on this material.
  40221. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40222. * This corresponds to a photographic exposure.
  40223. */
  40224. cameraExposure: number;
  40225. /**
  40226. * Gets The camera contrast used on this material.
  40227. */
  40228. /**
  40229. * Sets The camera contrast used on this material.
  40230. */
  40231. cameraContrast: number;
  40232. /**
  40233. * Gets the Color Grading 2D Lookup Texture.
  40234. */
  40235. /**
  40236. * Sets the Color Grading 2D Lookup Texture.
  40237. */
  40238. cameraColorGradingTexture: Nullable<BaseTexture>;
  40239. /**
  40240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40242. * 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;
  40243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40244. */
  40245. /**
  40246. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40247. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40248. * 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;
  40249. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40250. */
  40251. cameraColorCurves: Nullable<ColorCurves>;
  40252. /**
  40253. * Custom callback helping to override the default shader used in the material.
  40254. */
  40255. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40256. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40257. protected _worldViewProjectionMatrix: Matrix;
  40258. protected _globalAmbientColor: Color3;
  40259. protected _useLogarithmicDepth: boolean;
  40260. protected _rebuildInParallel: boolean;
  40261. /**
  40262. * Instantiates a new standard material.
  40263. * This is the default material used in Babylon. It is the best trade off between quality
  40264. * and performances.
  40265. * @see http://doc.babylonjs.com/babylon101/materials
  40266. * @param name Define the name of the material in the scene
  40267. * @param scene Define the scene the material belong to
  40268. */
  40269. constructor(name: string, scene: Scene);
  40270. /**
  40271. * Gets a boolean indicating that current material needs to register RTT
  40272. */
  40273. readonly hasRenderTargetTextures: boolean;
  40274. /**
  40275. * Gets the current class name of the material e.g. "StandardMaterial"
  40276. * Mainly use in serialization.
  40277. * @returns the class name
  40278. */
  40279. getClassName(): string;
  40280. /**
  40281. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40282. * You can try switching to logarithmic depth.
  40283. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40284. */
  40285. useLogarithmicDepth: boolean;
  40286. /**
  40287. * Specifies if the material will require alpha blending
  40288. * @returns a boolean specifying if alpha blending is needed
  40289. */
  40290. needAlphaBlending(): boolean;
  40291. /**
  40292. * Specifies if this material should be rendered in alpha test mode
  40293. * @returns a boolean specifying if an alpha test is needed.
  40294. */
  40295. needAlphaTesting(): boolean;
  40296. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40297. /**
  40298. * Get the texture used for alpha test purpose.
  40299. * @returns the diffuse texture in case of the standard material.
  40300. */
  40301. getAlphaTestTexture(): Nullable<BaseTexture>;
  40302. /**
  40303. * Get if the submesh is ready to be used and all its information available.
  40304. * Child classes can use it to update shaders
  40305. * @param mesh defines the mesh to check
  40306. * @param subMesh defines which submesh to check
  40307. * @param useInstances specifies that instances should be used
  40308. * @returns a boolean indicating that the submesh is ready or not
  40309. */
  40310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40311. /**
  40312. * Builds the material UBO layouts.
  40313. * Used internally during the effect preparation.
  40314. */
  40315. buildUniformLayout(): void;
  40316. /**
  40317. * Unbinds the material from the mesh
  40318. */
  40319. unbind(): void;
  40320. /**
  40321. * Binds the submesh to this material by preparing the effect and shader to draw
  40322. * @param world defines the world transformation matrix
  40323. * @param mesh defines the mesh containing the submesh
  40324. * @param subMesh defines the submesh to bind the material to
  40325. */
  40326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40327. /**
  40328. * Get the list of animatables in the material.
  40329. * @returns the list of animatables object used in the material
  40330. */
  40331. getAnimatables(): IAnimatable[];
  40332. /**
  40333. * Gets the active textures from the material
  40334. * @returns an array of textures
  40335. */
  40336. getActiveTextures(): BaseTexture[];
  40337. /**
  40338. * Specifies if the material uses a texture
  40339. * @param texture defines the texture to check against the material
  40340. * @returns a boolean specifying if the material uses the texture
  40341. */
  40342. hasTexture(texture: BaseTexture): boolean;
  40343. /**
  40344. * Disposes the material
  40345. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40346. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40347. */
  40348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40349. /**
  40350. * Makes a duplicate of the material, and gives it a new name
  40351. * @param name defines the new name for the duplicated material
  40352. * @returns the cloned material
  40353. */
  40354. clone(name: string): StandardMaterial;
  40355. /**
  40356. * Serializes this material in a JSON representation
  40357. * @returns the serialized material object
  40358. */
  40359. serialize(): any;
  40360. /**
  40361. * Creates a standard material from parsed material data
  40362. * @param source defines the JSON representation of the material
  40363. * @param scene defines the hosting scene
  40364. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40365. * @returns a new standard material
  40366. */
  40367. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40368. /**
  40369. * Are diffuse textures enabled in the application.
  40370. */
  40371. static DiffuseTextureEnabled: boolean;
  40372. /**
  40373. * Are ambient textures enabled in the application.
  40374. */
  40375. static AmbientTextureEnabled: boolean;
  40376. /**
  40377. * Are opacity textures enabled in the application.
  40378. */
  40379. static OpacityTextureEnabled: boolean;
  40380. /**
  40381. * Are reflection textures enabled in the application.
  40382. */
  40383. static ReflectionTextureEnabled: boolean;
  40384. /**
  40385. * Are emissive textures enabled in the application.
  40386. */
  40387. static EmissiveTextureEnabled: boolean;
  40388. /**
  40389. * Are specular textures enabled in the application.
  40390. */
  40391. static SpecularTextureEnabled: boolean;
  40392. /**
  40393. * Are bump textures enabled in the application.
  40394. */
  40395. static BumpTextureEnabled: boolean;
  40396. /**
  40397. * Are lightmap textures enabled in the application.
  40398. */
  40399. static LightmapTextureEnabled: boolean;
  40400. /**
  40401. * Are refraction textures enabled in the application.
  40402. */
  40403. static RefractionTextureEnabled: boolean;
  40404. /**
  40405. * Are color grading textures enabled in the application.
  40406. */
  40407. static ColorGradingTextureEnabled: boolean;
  40408. /**
  40409. * Are fresnels enabled in the application.
  40410. */
  40411. static FresnelEnabled: boolean;
  40412. }
  40413. }
  40414. declare module BABYLON {
  40415. /**
  40416. * A class extending Texture allowing drawing on a texture
  40417. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40418. */
  40419. export class DynamicTexture extends Texture {
  40420. private _generateMipMaps;
  40421. private _canvas;
  40422. private _context;
  40423. private _engine;
  40424. /**
  40425. * Creates a DynamicTexture
  40426. * @param name defines the name of the texture
  40427. * @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
  40428. * @param scene defines the scene where you want the texture
  40429. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40430. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40431. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40432. */
  40433. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40434. /**
  40435. * Get the current class name of the texture useful for serialization or dynamic coding.
  40436. * @returns "DynamicTexture"
  40437. */
  40438. getClassName(): string;
  40439. /**
  40440. * Gets the current state of canRescale
  40441. */
  40442. readonly canRescale: boolean;
  40443. private _recreate;
  40444. /**
  40445. * Scales the texture
  40446. * @param ratio the scale factor to apply to both width and height
  40447. */
  40448. scale(ratio: number): void;
  40449. /**
  40450. * Resizes the texture
  40451. * @param width the new width
  40452. * @param height the new height
  40453. */
  40454. scaleTo(width: number, height: number): void;
  40455. /**
  40456. * Gets the context of the canvas used by the texture
  40457. * @returns the canvas context of the dynamic texture
  40458. */
  40459. getContext(): CanvasRenderingContext2D;
  40460. /**
  40461. * Clears the texture
  40462. */
  40463. clear(): void;
  40464. /**
  40465. * Updates the texture
  40466. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40467. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40468. */
  40469. update(invertY?: boolean, premulAlpha?: boolean): void;
  40470. /**
  40471. * Draws text onto the texture
  40472. * @param text defines the text to be drawn
  40473. * @param x defines the placement of the text from the left
  40474. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40475. * @param font defines the font to be used with font-style, font-size, font-name
  40476. * @param color defines the color used for the text
  40477. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40478. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40479. * @param update defines whether texture is immediately update (default is true)
  40480. */
  40481. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40482. /**
  40483. * Clones the texture
  40484. * @returns the clone of the texture.
  40485. */
  40486. clone(): DynamicTexture;
  40487. /**
  40488. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40489. * @returns a serialized dynamic texture object
  40490. */
  40491. serialize(): any;
  40492. /** @hidden */
  40493. _rebuild(): void;
  40494. }
  40495. }
  40496. declare module BABYLON {
  40497. /** @hidden */
  40498. export var imageProcessingPixelShader: {
  40499. name: string;
  40500. shader: string;
  40501. };
  40502. }
  40503. declare module BABYLON {
  40504. /**
  40505. * ImageProcessingPostProcess
  40506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40507. */
  40508. export class ImageProcessingPostProcess extends PostProcess {
  40509. /**
  40510. * Default configuration related to image processing available in the PBR Material.
  40511. */
  40512. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40513. /**
  40514. * Gets the image processing configuration used either in this material.
  40515. */
  40516. /**
  40517. * Sets the Default image processing configuration used either in the this material.
  40518. *
  40519. * If sets to null, the scene one is in use.
  40520. */
  40521. imageProcessingConfiguration: ImageProcessingConfiguration;
  40522. /**
  40523. * Keep track of the image processing observer to allow dispose and replace.
  40524. */
  40525. private _imageProcessingObserver;
  40526. /**
  40527. * Attaches a new image processing configuration to the PBR Material.
  40528. * @param configuration
  40529. */
  40530. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40531. /**
  40532. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40533. */
  40534. /**
  40535. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40536. */
  40537. colorCurves: Nullable<ColorCurves>;
  40538. /**
  40539. * Gets wether the color curves effect is enabled.
  40540. */
  40541. /**
  40542. * Sets wether the color curves effect is enabled.
  40543. */
  40544. colorCurvesEnabled: boolean;
  40545. /**
  40546. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40547. */
  40548. /**
  40549. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40550. */
  40551. colorGradingTexture: Nullable<BaseTexture>;
  40552. /**
  40553. * Gets wether the color grading effect is enabled.
  40554. */
  40555. /**
  40556. * Gets wether the color grading effect is enabled.
  40557. */
  40558. colorGradingEnabled: boolean;
  40559. /**
  40560. * Gets exposure used in the effect.
  40561. */
  40562. /**
  40563. * Sets exposure used in the effect.
  40564. */
  40565. exposure: number;
  40566. /**
  40567. * Gets wether tonemapping is enabled or not.
  40568. */
  40569. /**
  40570. * Sets wether tonemapping is enabled or not
  40571. */
  40572. toneMappingEnabled: boolean;
  40573. /**
  40574. * Gets the type of tone mapping effect.
  40575. */
  40576. /**
  40577. * Sets the type of tone mapping effect.
  40578. */
  40579. toneMappingType: number;
  40580. /**
  40581. * Gets contrast used in the effect.
  40582. */
  40583. /**
  40584. * Sets contrast used in the effect.
  40585. */
  40586. contrast: number;
  40587. /**
  40588. * Gets Vignette stretch size.
  40589. */
  40590. /**
  40591. * Sets Vignette stretch size.
  40592. */
  40593. vignetteStretch: number;
  40594. /**
  40595. * Gets Vignette centre X Offset.
  40596. */
  40597. /**
  40598. * Sets Vignette centre X Offset.
  40599. */
  40600. vignetteCentreX: number;
  40601. /**
  40602. * Gets Vignette centre Y Offset.
  40603. */
  40604. /**
  40605. * Sets Vignette centre Y Offset.
  40606. */
  40607. vignetteCentreY: number;
  40608. /**
  40609. * Gets Vignette weight or intensity of the vignette effect.
  40610. */
  40611. /**
  40612. * Sets Vignette weight or intensity of the vignette effect.
  40613. */
  40614. vignetteWeight: number;
  40615. /**
  40616. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40617. * if vignetteEnabled is set to true.
  40618. */
  40619. /**
  40620. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40621. * if vignetteEnabled is set to true.
  40622. */
  40623. vignetteColor: Color4;
  40624. /**
  40625. * Gets Camera field of view used by the Vignette effect.
  40626. */
  40627. /**
  40628. * Sets Camera field of view used by the Vignette effect.
  40629. */
  40630. vignetteCameraFov: number;
  40631. /**
  40632. * Gets the vignette blend mode allowing different kind of effect.
  40633. */
  40634. /**
  40635. * Sets the vignette blend mode allowing different kind of effect.
  40636. */
  40637. vignetteBlendMode: number;
  40638. /**
  40639. * Gets wether the vignette effect is enabled.
  40640. */
  40641. /**
  40642. * Sets wether the vignette effect is enabled.
  40643. */
  40644. vignetteEnabled: boolean;
  40645. private _fromLinearSpace;
  40646. /**
  40647. * Gets wether the input of the processing is in Gamma or Linear Space.
  40648. */
  40649. /**
  40650. * Sets wether the input of the processing is in Gamma or Linear Space.
  40651. */
  40652. fromLinearSpace: boolean;
  40653. /**
  40654. * Defines cache preventing GC.
  40655. */
  40656. private _defines;
  40657. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40658. /**
  40659. * "ImageProcessingPostProcess"
  40660. * @returns "ImageProcessingPostProcess"
  40661. */
  40662. getClassName(): string;
  40663. protected _updateParameters(): void;
  40664. dispose(camera?: Camera): void;
  40665. }
  40666. }
  40667. declare module BABYLON {
  40668. /**
  40669. * Class containing static functions to help procedurally build meshes
  40670. */
  40671. export class GroundBuilder {
  40672. /**
  40673. * Creates a ground mesh
  40674. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40675. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40677. * @param name defines the name of the mesh
  40678. * @param options defines the options used to create the mesh
  40679. * @param scene defines the hosting scene
  40680. * @returns the ground mesh
  40681. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40682. */
  40683. static CreateGround(name: string, options: {
  40684. width?: number;
  40685. height?: number;
  40686. subdivisions?: number;
  40687. subdivisionsX?: number;
  40688. subdivisionsY?: number;
  40689. updatable?: boolean;
  40690. }, scene: any): Mesh;
  40691. /**
  40692. * Creates a tiled ground mesh
  40693. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40694. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40695. * * 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
  40696. * * 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
  40697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40698. * @param name defines the name of the mesh
  40699. * @param options defines the options used to create the mesh
  40700. * @param scene defines the hosting scene
  40701. * @returns the tiled ground mesh
  40702. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40703. */
  40704. static CreateTiledGround(name: string, options: {
  40705. xmin: number;
  40706. zmin: number;
  40707. xmax: number;
  40708. zmax: number;
  40709. subdivisions?: {
  40710. w: number;
  40711. h: number;
  40712. };
  40713. precision?: {
  40714. w: number;
  40715. h: number;
  40716. };
  40717. updatable?: boolean;
  40718. }, scene?: Nullable<Scene>): Mesh;
  40719. /**
  40720. * Creates a ground mesh from a height map
  40721. * * The parameter `url` sets the URL of the height map image resource.
  40722. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40723. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40724. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40725. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40726. * * 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.
  40727. * * 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).
  40728. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40730. * @param name defines the name of the mesh
  40731. * @param url defines the url to the height map
  40732. * @param options defines the options used to create the mesh
  40733. * @param scene defines the hosting scene
  40734. * @returns the ground mesh
  40735. * @see https://doc.babylonjs.com/babylon101/height_map
  40736. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40737. */
  40738. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40739. width?: number;
  40740. height?: number;
  40741. subdivisions?: number;
  40742. minHeight?: number;
  40743. maxHeight?: number;
  40744. colorFilter?: Color3;
  40745. alphaFilter?: number;
  40746. updatable?: boolean;
  40747. onReady?: (mesh: GroundMesh) => void;
  40748. }, scene?: Nullable<Scene>): GroundMesh;
  40749. }
  40750. }
  40751. declare module BABYLON {
  40752. /**
  40753. * Class containing static functions to help procedurally build meshes
  40754. */
  40755. export class TorusBuilder {
  40756. /**
  40757. * Creates a torus mesh
  40758. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40759. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40760. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40762. * * 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
  40763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40764. * @param name defines the name of the mesh
  40765. * @param options defines the options used to create the mesh
  40766. * @param scene defines the hosting scene
  40767. * @returns the torus mesh
  40768. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40769. */
  40770. static CreateTorus(name: string, options: {
  40771. diameter?: number;
  40772. thickness?: number;
  40773. tessellation?: number;
  40774. updatable?: boolean;
  40775. sideOrientation?: number;
  40776. frontUVs?: Vector4;
  40777. backUVs?: Vector4;
  40778. }, scene: any): Mesh;
  40779. }
  40780. }
  40781. declare module BABYLON {
  40782. /**
  40783. * Class containing static functions to help procedurally build meshes
  40784. */
  40785. export class CylinderBuilder {
  40786. /**
  40787. * Creates a cylinder or a cone mesh
  40788. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40789. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40790. * * 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.
  40791. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40792. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40793. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40794. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40795. * * 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).
  40796. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40797. * * 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).
  40798. * * 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
  40799. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40800. * * 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
  40801. * * 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.
  40802. * * If `enclose` is false, a ring surface is one element.
  40803. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40804. * * 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
  40805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40806. * * 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
  40807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40808. * @param name defines the name of the mesh
  40809. * @param options defines the options used to create the mesh
  40810. * @param scene defines the hosting scene
  40811. * @returns the cylinder mesh
  40812. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40813. */
  40814. static CreateCylinder(name: string, options: {
  40815. height?: number;
  40816. diameterTop?: number;
  40817. diameterBottom?: number;
  40818. diameter?: number;
  40819. tessellation?: number;
  40820. subdivisions?: number;
  40821. arc?: number;
  40822. faceColors?: Color4[];
  40823. faceUV?: Vector4[];
  40824. updatable?: boolean;
  40825. hasRings?: boolean;
  40826. enclose?: boolean;
  40827. cap?: number;
  40828. sideOrientation?: number;
  40829. frontUVs?: Vector4;
  40830. backUVs?: Vector4;
  40831. }, scene: any): Mesh;
  40832. }
  40833. }
  40834. declare module BABYLON {
  40835. /**
  40836. * Options to modify the vr teleportation behavior.
  40837. */
  40838. export interface VRTeleportationOptions {
  40839. /**
  40840. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40841. */
  40842. floorMeshName?: string;
  40843. /**
  40844. * A list of meshes to be used as the teleportation floor. (default: empty)
  40845. */
  40846. floorMeshes?: Mesh[];
  40847. }
  40848. /**
  40849. * Options to modify the vr experience helper's behavior.
  40850. */
  40851. export interface VRExperienceHelperOptions extends WebVROptions {
  40852. /**
  40853. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40854. */
  40855. createDeviceOrientationCamera?: boolean;
  40856. /**
  40857. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40858. */
  40859. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40860. /**
  40861. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40862. */
  40863. laserToggle?: boolean;
  40864. /**
  40865. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40866. */
  40867. floorMeshes?: Mesh[];
  40868. /**
  40869. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40870. */
  40871. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40872. }
  40873. /**
  40874. * Event containing information after VR has been entered
  40875. */
  40876. export class OnAfterEnteringVRObservableEvent {
  40877. /**
  40878. * If entering vr was successful
  40879. */
  40880. success: boolean;
  40881. }
  40882. /**
  40883. * Helps to quickly add VR support to an existing scene.
  40884. * See http://doc.babylonjs.com/how_to/webvr_helper
  40885. */
  40886. export class VRExperienceHelper {
  40887. /** Options to modify the vr experience helper's behavior. */
  40888. webVROptions: VRExperienceHelperOptions;
  40889. private _scene;
  40890. private _position;
  40891. private _btnVR;
  40892. private _btnVRDisplayed;
  40893. private _webVRsupported;
  40894. private _webVRready;
  40895. private _webVRrequesting;
  40896. private _webVRpresenting;
  40897. private _hasEnteredVR;
  40898. private _fullscreenVRpresenting;
  40899. private _canvas;
  40900. private _webVRCamera;
  40901. private _vrDeviceOrientationCamera;
  40902. private _deviceOrientationCamera;
  40903. private _existingCamera;
  40904. private _onKeyDown;
  40905. private _onVrDisplayPresentChange;
  40906. private _onVRDisplayChanged;
  40907. private _onVRRequestPresentStart;
  40908. private _onVRRequestPresentComplete;
  40909. /**
  40910. * 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)
  40911. */
  40912. enableGazeEvenWhenNoPointerLock: boolean;
  40913. /**
  40914. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40915. */
  40916. exitVROnDoubleTap: boolean;
  40917. /**
  40918. * Observable raised right before entering VR.
  40919. */
  40920. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40921. /**
  40922. * Observable raised when entering VR has completed.
  40923. */
  40924. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40925. /**
  40926. * Observable raised when exiting VR.
  40927. */
  40928. onExitingVRObservable: Observable<VRExperienceHelper>;
  40929. /**
  40930. * Observable raised when controller mesh is loaded.
  40931. */
  40932. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40933. /** Return this.onEnteringVRObservable
  40934. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40935. */
  40936. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40937. /** Return this.onExitingVRObservable
  40938. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40939. */
  40940. readonly onExitingVR: Observable<VRExperienceHelper>;
  40941. /** Return this.onControllerMeshLoadedObservable
  40942. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40943. */
  40944. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40945. private _rayLength;
  40946. private _useCustomVRButton;
  40947. private _teleportationRequested;
  40948. private _teleportActive;
  40949. private _floorMeshName;
  40950. private _floorMeshesCollection;
  40951. private _rotationAllowed;
  40952. private _teleportBackwardsVector;
  40953. private _teleportationTarget;
  40954. private _isDefaultTeleportationTarget;
  40955. private _postProcessMove;
  40956. private _teleportationFillColor;
  40957. private _teleportationBorderColor;
  40958. private _rotationAngle;
  40959. private _haloCenter;
  40960. private _cameraGazer;
  40961. private _padSensibilityUp;
  40962. private _padSensibilityDown;
  40963. private _leftController;
  40964. private _rightController;
  40965. /**
  40966. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40967. */
  40968. onNewMeshSelected: Observable<AbstractMesh>;
  40969. /**
  40970. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40971. * This observable will provide the mesh and the controller used to select the mesh
  40972. */
  40973. onMeshSelectedWithController: Observable<{
  40974. mesh: AbstractMesh;
  40975. controller: WebVRController;
  40976. }>;
  40977. /**
  40978. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40979. */
  40980. onNewMeshPicked: Observable<PickingInfo>;
  40981. private _circleEase;
  40982. /**
  40983. * Observable raised before camera teleportation
  40984. */
  40985. onBeforeCameraTeleport: Observable<Vector3>;
  40986. /**
  40987. * Observable raised after camera teleportation
  40988. */
  40989. onAfterCameraTeleport: Observable<Vector3>;
  40990. /**
  40991. * Observable raised when current selected mesh gets unselected
  40992. */
  40993. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40994. private _raySelectionPredicate;
  40995. /**
  40996. * To be optionaly changed by user to define custom ray selection
  40997. */
  40998. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40999. /**
  41000. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41001. */
  41002. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41003. /**
  41004. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41005. */
  41006. teleportationEnabled: boolean;
  41007. private _defaultHeight;
  41008. private _teleportationInitialized;
  41009. private _interactionsEnabled;
  41010. private _interactionsRequested;
  41011. private _displayGaze;
  41012. private _displayLaserPointer;
  41013. /**
  41014. * The mesh used to display where the user is going to teleport.
  41015. */
  41016. /**
  41017. * Sets the mesh to be used to display where the user is going to teleport.
  41018. */
  41019. teleportationTarget: Mesh;
  41020. /**
  41021. * 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
  41022. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41023. * See http://doc.babylonjs.com/resources/baking_transformations
  41024. */
  41025. gazeTrackerMesh: Mesh;
  41026. /**
  41027. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41028. */
  41029. updateGazeTrackerScale: boolean;
  41030. /**
  41031. * If the gaze trackers color should be updated when selecting meshes
  41032. */
  41033. updateGazeTrackerColor: boolean;
  41034. /**
  41035. * If the controller laser color should be updated when selecting meshes
  41036. */
  41037. updateControllerLaserColor: boolean;
  41038. /**
  41039. * The gaze tracking mesh corresponding to the left controller
  41040. */
  41041. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41042. /**
  41043. * The gaze tracking mesh corresponding to the right controller
  41044. */
  41045. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41046. /**
  41047. * If the ray of the gaze should be displayed.
  41048. */
  41049. /**
  41050. * Sets if the ray of the gaze should be displayed.
  41051. */
  41052. displayGaze: boolean;
  41053. /**
  41054. * If the ray of the LaserPointer should be displayed.
  41055. */
  41056. /**
  41057. * Sets if the ray of the LaserPointer should be displayed.
  41058. */
  41059. displayLaserPointer: boolean;
  41060. /**
  41061. * The deviceOrientationCamera used as the camera when not in VR.
  41062. */
  41063. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41064. /**
  41065. * Based on the current WebVR support, returns the current VR camera used.
  41066. */
  41067. readonly currentVRCamera: Nullable<Camera>;
  41068. /**
  41069. * The webVRCamera which is used when in VR.
  41070. */
  41071. readonly webVRCamera: WebVRFreeCamera;
  41072. /**
  41073. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41074. */
  41075. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41076. /**
  41077. * The html button that is used to trigger entering into VR.
  41078. */
  41079. readonly vrButton: Nullable<HTMLButtonElement>;
  41080. private readonly _teleportationRequestInitiated;
  41081. /**
  41082. * Defines wether or not Pointer lock should be requested when switching to
  41083. * full screen.
  41084. */
  41085. requestPointerLockOnFullScreen: boolean;
  41086. /**
  41087. * Instantiates a VRExperienceHelper.
  41088. * Helps to quickly add VR support to an existing scene.
  41089. * @param scene The scene the VRExperienceHelper belongs to.
  41090. * @param webVROptions Options to modify the vr experience helper's behavior.
  41091. */
  41092. constructor(scene: Scene,
  41093. /** Options to modify the vr experience helper's behavior. */
  41094. webVROptions?: VRExperienceHelperOptions);
  41095. private _onDefaultMeshLoaded;
  41096. private _onResize;
  41097. private _onFullscreenChange;
  41098. /**
  41099. * Gets a value indicating if we are currently in VR mode.
  41100. */
  41101. readonly isInVRMode: boolean;
  41102. private onVrDisplayPresentChange;
  41103. private onVRDisplayChanged;
  41104. private moveButtonToBottomRight;
  41105. private displayVRButton;
  41106. private updateButtonVisibility;
  41107. private _cachedAngularSensibility;
  41108. /**
  41109. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41110. * Otherwise, will use the fullscreen API.
  41111. */
  41112. enterVR(): void;
  41113. /**
  41114. * Attempt to exit VR, or fullscreen.
  41115. */
  41116. exitVR(): void;
  41117. /**
  41118. * The position of the vr experience helper.
  41119. */
  41120. /**
  41121. * Sets the position of the vr experience helper.
  41122. */
  41123. position: Vector3;
  41124. /**
  41125. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41126. */
  41127. enableInteractions(): void;
  41128. private readonly _noControllerIsActive;
  41129. private beforeRender;
  41130. private _isTeleportationFloor;
  41131. /**
  41132. * Adds a floor mesh to be used for teleportation.
  41133. * @param floorMesh the mesh to be used for teleportation.
  41134. */
  41135. addFloorMesh(floorMesh: Mesh): void;
  41136. /**
  41137. * Removes a floor mesh from being used for teleportation.
  41138. * @param floorMesh the mesh to be removed.
  41139. */
  41140. removeFloorMesh(floorMesh: Mesh): void;
  41141. /**
  41142. * Enables interactions and teleportation using the VR controllers and gaze.
  41143. * @param vrTeleportationOptions options to modify teleportation behavior.
  41144. */
  41145. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41146. private _onNewGamepadConnected;
  41147. private _tryEnableInteractionOnController;
  41148. private _onNewGamepadDisconnected;
  41149. private _enableInteractionOnController;
  41150. private _checkTeleportWithRay;
  41151. private _checkRotate;
  41152. private _checkTeleportBackwards;
  41153. private _enableTeleportationOnController;
  41154. private _createTeleportationCircles;
  41155. private _displayTeleportationTarget;
  41156. private _hideTeleportationTarget;
  41157. private _rotateCamera;
  41158. private _moveTeleportationSelectorTo;
  41159. private _workingVector;
  41160. private _workingQuaternion;
  41161. private _workingMatrix;
  41162. /**
  41163. * Teleports the users feet to the desired location
  41164. * @param location The location where the user's feet should be placed
  41165. */
  41166. teleportCamera(location: Vector3): void;
  41167. private _convertNormalToDirectionOfRay;
  41168. private _castRayAndSelectObject;
  41169. private _notifySelectedMeshUnselected;
  41170. /**
  41171. * Sets the color of the laser ray from the vr controllers.
  41172. * @param color new color for the ray.
  41173. */
  41174. changeLaserColor(color: Color3): void;
  41175. /**
  41176. * Sets the color of the ray from the vr headsets gaze.
  41177. * @param color new color for the ray.
  41178. */
  41179. changeGazeColor(color: Color3): void;
  41180. /**
  41181. * Exits VR and disposes of the vr experience helper
  41182. */
  41183. dispose(): void;
  41184. /**
  41185. * Gets the name of the VRExperienceHelper class
  41186. * @returns "VRExperienceHelper"
  41187. */
  41188. getClassName(): string;
  41189. }
  41190. }
  41191. declare module BABYLON {
  41192. /**
  41193. * Manages an XRSession to work with Babylon's engine
  41194. * @see https://doc.babylonjs.com/how_to/webxr
  41195. */
  41196. export class WebXRSessionManager implements IDisposable {
  41197. private scene;
  41198. /**
  41199. * Fires every time a new xrFrame arrives which can be used to update the camera
  41200. */
  41201. onXRFrameObservable: Observable<any>;
  41202. /**
  41203. * Fires when the xr session is ended either by the device or manually done
  41204. */
  41205. onXRSessionEnded: Observable<any>;
  41206. /**
  41207. * Underlying xr session
  41208. */
  41209. session: XRSession;
  41210. /**
  41211. * Type of reference space used when creating the session
  41212. */
  41213. referenceSpace: XRReferenceSpace;
  41214. /** @hidden */
  41215. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41216. /**
  41217. * Current XR frame
  41218. */
  41219. currentFrame: Nullable<XRFrame>;
  41220. private _xrNavigator;
  41221. private baseLayer;
  41222. /**
  41223. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41224. * @param scene The scene which the session should be created for
  41225. */
  41226. constructor(scene: Scene);
  41227. /**
  41228. * Initializes the manager
  41229. * After initialization enterXR can be called to start an XR session
  41230. * @returns Promise which resolves after it is initialized
  41231. */
  41232. initializeAsync(): Promise<void>;
  41233. /**
  41234. * Initializes an xr session
  41235. * @param xrSessionMode mode to initialize
  41236. * @returns a promise which will resolve once the session has been initialized
  41237. */
  41238. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41239. /**
  41240. * Sets the reference space on the xr session
  41241. * @param referenceSpace space to set
  41242. * @returns a promise that will resolve once the reference space has been set
  41243. */
  41244. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41245. /**
  41246. * Updates the render state of the session
  41247. * @param state state to set
  41248. * @returns a promise that resolves once the render state has been updated
  41249. */
  41250. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41251. /**
  41252. * Starts rendering to the xr layer
  41253. * @returns a promise that will resolve once rendering has started
  41254. */
  41255. startRenderingToXRAsync(): Promise<void>;
  41256. /**
  41257. * Stops the xrSession and restores the renderloop
  41258. * @returns Promise which resolves after it exits XR
  41259. */
  41260. exitXRAsync(): Promise<unknown>;
  41261. /**
  41262. * Checks if a session would be supported for the creation options specified
  41263. * @param sessionMode session mode to check if supported eg. immersive-vr
  41264. * @returns true if supported
  41265. */
  41266. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41267. /**
  41268. * @hidden
  41269. * Converts the render layer of xrSession to a render target
  41270. * @param session session to create render target for
  41271. * @param scene scene the new render target should be created for
  41272. */
  41273. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41274. /**
  41275. * Disposes of the session manager
  41276. */
  41277. dispose(): void;
  41278. }
  41279. }
  41280. declare module BABYLON {
  41281. /**
  41282. * WebXR Camera which holds the views for the xrSession
  41283. * @see https://doc.babylonjs.com/how_to/webxr
  41284. */
  41285. export class WebXRCamera extends FreeCamera {
  41286. private static _TmpMatrix;
  41287. /**
  41288. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41289. * @param name the name of the camera
  41290. * @param scene the scene to add the camera to
  41291. */
  41292. constructor(name: string, scene: Scene);
  41293. private _updateNumberOfRigCameras;
  41294. /** @hidden */
  41295. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41296. /**
  41297. * Updates the cameras position from the current pose information of the XR session
  41298. * @param xrSessionManager the session containing pose information
  41299. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41300. */
  41301. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41302. }
  41303. }
  41304. declare module BABYLON {
  41305. /**
  41306. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41307. */
  41308. export class WebXRManagedOutputCanvas implements IDisposable {
  41309. private helper;
  41310. private _canvas;
  41311. /**
  41312. * xrpresent context of the canvas which can be used to display/mirror xr content
  41313. */
  41314. canvasContext: WebGLRenderingContext;
  41315. /**
  41316. * xr layer for the canvas
  41317. */
  41318. xrLayer: Nullable<XRWebGLLayer>;
  41319. /**
  41320. * Initializes the xr layer for the session
  41321. * @param xrSession xr session
  41322. * @returns a promise that will resolve once the XR Layer has been created
  41323. */
  41324. initializeXRLayerAsync(xrSession: any): any;
  41325. /**
  41326. * Initializes the canvas to be added/removed upon entering/exiting xr
  41327. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41328. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41329. */
  41330. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41331. /**
  41332. * Disposes of the object
  41333. */
  41334. dispose(): void;
  41335. private _setManagedOutputCanvas;
  41336. private _addCanvas;
  41337. private _removeCanvas;
  41338. }
  41339. }
  41340. declare module BABYLON {
  41341. /**
  41342. * States of the webXR experience
  41343. */
  41344. export enum WebXRState {
  41345. /**
  41346. * Transitioning to being in XR mode
  41347. */
  41348. ENTERING_XR = 0,
  41349. /**
  41350. * Transitioning to non XR mode
  41351. */
  41352. EXITING_XR = 1,
  41353. /**
  41354. * In XR mode and presenting
  41355. */
  41356. IN_XR = 2,
  41357. /**
  41358. * Not entered XR mode
  41359. */
  41360. NOT_IN_XR = 3
  41361. }
  41362. /**
  41363. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41364. * @see https://doc.babylonjs.com/how_to/webxr
  41365. */
  41366. export class WebXRExperienceHelper implements IDisposable {
  41367. private scene;
  41368. /**
  41369. * 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
  41370. */
  41371. container: AbstractMesh;
  41372. /**
  41373. * Camera used to render xr content
  41374. */
  41375. camera: WebXRCamera;
  41376. /**
  41377. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41378. */
  41379. state: WebXRState;
  41380. private _setState;
  41381. private static _TmpVector;
  41382. /**
  41383. * Fires when the state of the experience helper has changed
  41384. */
  41385. onStateChangedObservable: Observable<WebXRState>;
  41386. /** Session manager used to keep track of xr session */
  41387. sessionManager: WebXRSessionManager;
  41388. private _nonVRCamera;
  41389. private _originalSceneAutoClear;
  41390. private _supported;
  41391. /**
  41392. * Creates the experience helper
  41393. * @param scene the scene to attach the experience helper to
  41394. * @returns a promise for the experience helper
  41395. */
  41396. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41397. /**
  41398. * Creates a WebXRExperienceHelper
  41399. * @param scene The scene the helper should be created in
  41400. */
  41401. private constructor();
  41402. /**
  41403. * Exits XR mode and returns the scene to its original state
  41404. * @returns promise that resolves after xr mode has exited
  41405. */
  41406. exitXRAsync(): Promise<unknown>;
  41407. /**
  41408. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41409. * @param sessionCreationOptions options for the XR session
  41410. * @param referenceSpaceType frame of reference of the XR session
  41411. * @param outputCanvas the output canvas that will be used to enter XR mode
  41412. * @returns promise that resolves after xr mode has entered
  41413. */
  41414. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41415. /**
  41416. * Updates the global position of the camera by moving the camera's container
  41417. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41418. * @param position The desired global position of the camera
  41419. */
  41420. setPositionOfCameraUsingContainer(position: Vector3): void;
  41421. /**
  41422. * Rotates the xr camera by rotating the camera's container around the camera's position
  41423. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41424. * @param rotation the desired quaternion rotation to apply to the camera
  41425. */
  41426. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41427. /**
  41428. * Disposes of the experience helper
  41429. */
  41430. dispose(): void;
  41431. }
  41432. }
  41433. declare module BABYLON {
  41434. /**
  41435. * Button which can be used to enter a different mode of XR
  41436. */
  41437. export class WebXREnterExitUIButton {
  41438. /** button element */
  41439. element: HTMLElement;
  41440. /** XR initialization options for the button */
  41441. sessionMode: XRSessionMode;
  41442. /** Reference space type */
  41443. referenceSpaceType: XRReferenceSpaceType;
  41444. /**
  41445. * Creates a WebXREnterExitUIButton
  41446. * @param element button element
  41447. * @param sessionMode XR initialization session mode
  41448. * @param referenceSpaceType the type of reference space to be used
  41449. */
  41450. constructor(
  41451. /** button element */
  41452. element: HTMLElement,
  41453. /** XR initialization options for the button */
  41454. sessionMode: XRSessionMode,
  41455. /** Reference space type */
  41456. referenceSpaceType: XRReferenceSpaceType);
  41457. /**
  41458. * Overwritable function which can be used to update the button's visuals when the state changes
  41459. * @param activeButton the current active button in the UI
  41460. */
  41461. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41462. }
  41463. /**
  41464. * Options to create the webXR UI
  41465. */
  41466. export class WebXREnterExitUIOptions {
  41467. /**
  41468. * Context to enter xr with
  41469. */
  41470. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41471. /**
  41472. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41473. */
  41474. customButtons?: Array<WebXREnterExitUIButton>;
  41475. }
  41476. /**
  41477. * UI to allow the user to enter/exit XR mode
  41478. */
  41479. export class WebXREnterExitUI implements IDisposable {
  41480. private scene;
  41481. private _overlay;
  41482. private _buttons;
  41483. private _activeButton;
  41484. /**
  41485. * Fired every time the active button is changed.
  41486. *
  41487. * When xr is entered via a button that launches xr that button will be the callback parameter
  41488. *
  41489. * When exiting xr the callback parameter will be null)
  41490. */
  41491. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41492. /**
  41493. * Creates UI to allow the user to enter/exit XR mode
  41494. * @param scene the scene to add the ui to
  41495. * @param helper the xr experience helper to enter/exit xr with
  41496. * @param options options to configure the UI
  41497. * @returns the created ui
  41498. */
  41499. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41500. private constructor();
  41501. private _updateButtons;
  41502. /**
  41503. * Disposes of the object
  41504. */
  41505. dispose(): void;
  41506. }
  41507. }
  41508. declare module BABYLON {
  41509. /**
  41510. * Represents an XR input
  41511. */
  41512. export class WebXRController {
  41513. private scene;
  41514. /** The underlying input source for the controller */
  41515. inputSource: XRInputSource;
  41516. private parentContainer;
  41517. /**
  41518. * 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
  41519. */
  41520. grip?: AbstractMesh;
  41521. /**
  41522. * Pointer which can be used to select objects or attach a visible laser to
  41523. */
  41524. pointer: AbstractMesh;
  41525. /**
  41526. * Event that fires when the controller is removed/disposed
  41527. */
  41528. onDisposeObservable: Observable<{}>;
  41529. private _tmpMatrix;
  41530. private _tmpQuaternion;
  41531. private _tmpVector;
  41532. /**
  41533. * Creates the controller
  41534. * @see https://doc.babylonjs.com/how_to/webxr
  41535. * @param scene the scene which the controller should be associated to
  41536. * @param inputSource the underlying input source for the controller
  41537. * @param parentContainer parent that the controller meshes should be children of
  41538. */
  41539. constructor(scene: Scene,
  41540. /** The underlying input source for the controller */
  41541. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41542. /**
  41543. * Updates the controller pose based on the given XRFrame
  41544. * @param xrFrame xr frame to update the pose with
  41545. * @param referenceSpace reference space to use
  41546. */
  41547. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41548. /**
  41549. * Gets a world space ray coming from the controller
  41550. * @param result the resulting ray
  41551. */
  41552. getWorldPointerRayToRef(result: Ray): void;
  41553. /**
  41554. * Disposes of the object
  41555. */
  41556. dispose(): void;
  41557. }
  41558. }
  41559. declare module BABYLON {
  41560. /**
  41561. * XR input used to track XR inputs such as controllers/rays
  41562. */
  41563. export class WebXRInput implements IDisposable {
  41564. /**
  41565. * Base experience the input listens to
  41566. */
  41567. baseExperience: WebXRExperienceHelper;
  41568. /**
  41569. * XR controllers being tracked
  41570. */
  41571. controllers: Array<WebXRController>;
  41572. private _frameObserver;
  41573. private _stateObserver;
  41574. /**
  41575. * Event when a controller has been connected/added
  41576. */
  41577. onControllerAddedObservable: Observable<WebXRController>;
  41578. /**
  41579. * Event when a controller has been removed/disconnected
  41580. */
  41581. onControllerRemovedObservable: Observable<WebXRController>;
  41582. /**
  41583. * Initializes the WebXRInput
  41584. * @param baseExperience experience helper which the input should be created for
  41585. */
  41586. constructor(
  41587. /**
  41588. * Base experience the input listens to
  41589. */
  41590. baseExperience: WebXRExperienceHelper);
  41591. private _onInputSourcesChange;
  41592. private _addAndRemoveControllers;
  41593. /**
  41594. * Disposes of the object
  41595. */
  41596. dispose(): void;
  41597. }
  41598. }
  41599. declare module BABYLON {
  41600. /**
  41601. * Enables teleportation
  41602. */
  41603. export class WebXRControllerTeleportation {
  41604. private _teleportationFillColor;
  41605. private _teleportationBorderColor;
  41606. private _tmpRay;
  41607. private _tmpVector;
  41608. /**
  41609. * Creates a WebXRControllerTeleportation
  41610. * @param input input manager to add teleportation to
  41611. * @param floorMeshes floormeshes which can be teleported to
  41612. */
  41613. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41614. }
  41615. }
  41616. declare module BABYLON {
  41617. /**
  41618. * Handles pointer input automatically for the pointer of XR controllers
  41619. */
  41620. export class WebXRControllerPointerSelection {
  41621. private static _idCounter;
  41622. private _tmpRay;
  41623. /**
  41624. * Creates a WebXRControllerPointerSelection
  41625. * @param input input manager to setup pointer selection
  41626. */
  41627. constructor(input: WebXRInput);
  41628. private _convertNormalToDirectionOfRay;
  41629. private _updatePointerDistance;
  41630. }
  41631. }
  41632. declare module BABYLON {
  41633. /**
  41634. * Class used to represent data loading progression
  41635. */
  41636. export class SceneLoaderProgressEvent {
  41637. /** defines if data length to load can be evaluated */
  41638. readonly lengthComputable: boolean;
  41639. /** defines the loaded data length */
  41640. readonly loaded: number;
  41641. /** defines the data length to load */
  41642. readonly total: number;
  41643. /**
  41644. * Create a new progress event
  41645. * @param lengthComputable defines if data length to load can be evaluated
  41646. * @param loaded defines the loaded data length
  41647. * @param total defines the data length to load
  41648. */
  41649. constructor(
  41650. /** defines if data length to load can be evaluated */
  41651. lengthComputable: boolean,
  41652. /** defines the loaded data length */
  41653. loaded: number,
  41654. /** defines the data length to load */
  41655. total: number);
  41656. /**
  41657. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41658. * @param event defines the source event
  41659. * @returns a new SceneLoaderProgressEvent
  41660. */
  41661. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41662. }
  41663. /**
  41664. * Interface used by SceneLoader plugins to define supported file extensions
  41665. */
  41666. export interface ISceneLoaderPluginExtensions {
  41667. /**
  41668. * Defines the list of supported extensions
  41669. */
  41670. [extension: string]: {
  41671. isBinary: boolean;
  41672. };
  41673. }
  41674. /**
  41675. * Interface used by SceneLoader plugin factory
  41676. */
  41677. export interface ISceneLoaderPluginFactory {
  41678. /**
  41679. * Defines the name of the factory
  41680. */
  41681. name: string;
  41682. /**
  41683. * Function called to create a new plugin
  41684. * @return the new plugin
  41685. */
  41686. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41687. /**
  41688. * Boolean indicating if the plugin can direct load specific data
  41689. */
  41690. canDirectLoad?: (data: string) => boolean;
  41691. }
  41692. /**
  41693. * Interface used to define a SceneLoader plugin
  41694. */
  41695. export interface ISceneLoaderPlugin {
  41696. /**
  41697. * The friendly name of this plugin.
  41698. */
  41699. name: string;
  41700. /**
  41701. * The file extensions supported by this plugin.
  41702. */
  41703. extensions: string | ISceneLoaderPluginExtensions;
  41704. /**
  41705. * Import meshes into a scene.
  41706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41707. * @param scene The scene to import into
  41708. * @param data The data to import
  41709. * @param rootUrl The root url for scene and resources
  41710. * @param meshes The meshes array to import into
  41711. * @param particleSystems The particle systems array to import into
  41712. * @param skeletons The skeletons array to import into
  41713. * @param onError The callback when import fails
  41714. * @returns True if successful or false otherwise
  41715. */
  41716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41717. /**
  41718. * Load into a scene.
  41719. * @param scene The scene to load into
  41720. * @param data The data to import
  41721. * @param rootUrl The root url for scene and resources
  41722. * @param onError The callback when import fails
  41723. * @returns true if successful or false otherwise
  41724. */
  41725. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41726. /**
  41727. * The callback that returns true if the data can be directly loaded.
  41728. */
  41729. canDirectLoad?: (data: string) => boolean;
  41730. /**
  41731. * The callback that allows custom handling of the root url based on the response url.
  41732. */
  41733. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41734. /**
  41735. * Load into an asset container.
  41736. * @param scene The scene to load into
  41737. * @param data The data to import
  41738. * @param rootUrl The root url for scene and resources
  41739. * @param onError The callback when import fails
  41740. * @returns The loaded asset container
  41741. */
  41742. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41743. }
  41744. /**
  41745. * Interface used to define an async SceneLoader plugin
  41746. */
  41747. export interface ISceneLoaderPluginAsync {
  41748. /**
  41749. * The friendly name of this plugin.
  41750. */
  41751. name: string;
  41752. /**
  41753. * The file extensions supported by this plugin.
  41754. */
  41755. extensions: string | ISceneLoaderPluginExtensions;
  41756. /**
  41757. * Import meshes into a scene.
  41758. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41759. * @param scene The scene to import into
  41760. * @param data The data to import
  41761. * @param rootUrl The root url for scene and resources
  41762. * @param onProgress The callback when the load progresses
  41763. * @param fileName Defines the name of the file to load
  41764. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41765. */
  41766. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41767. meshes: AbstractMesh[];
  41768. particleSystems: IParticleSystem[];
  41769. skeletons: Skeleton[];
  41770. animationGroups: AnimationGroup[];
  41771. }>;
  41772. /**
  41773. * Load into a scene.
  41774. * @param scene The scene to load into
  41775. * @param data The data to import
  41776. * @param rootUrl The root url for scene and resources
  41777. * @param onProgress The callback when the load progresses
  41778. * @param fileName Defines the name of the file to load
  41779. * @returns Nothing
  41780. */
  41781. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41782. /**
  41783. * The callback that returns true if the data can be directly loaded.
  41784. */
  41785. canDirectLoad?: (data: string) => boolean;
  41786. /**
  41787. * The callback that allows custom handling of the root url based on the response url.
  41788. */
  41789. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41790. /**
  41791. * Load into an asset container.
  41792. * @param scene The scene to load into
  41793. * @param data The data to import
  41794. * @param rootUrl The root url for scene and resources
  41795. * @param onProgress The callback when the load progresses
  41796. * @param fileName Defines the name of the file to load
  41797. * @returns The loaded asset container
  41798. */
  41799. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41800. }
  41801. /**
  41802. * Class used to load scene from various file formats using registered plugins
  41803. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41804. */
  41805. export class SceneLoader {
  41806. /**
  41807. * No logging while loading
  41808. */
  41809. static readonly NO_LOGGING: number;
  41810. /**
  41811. * Minimal logging while loading
  41812. */
  41813. static readonly MINIMAL_LOGGING: number;
  41814. /**
  41815. * Summary logging while loading
  41816. */
  41817. static readonly SUMMARY_LOGGING: number;
  41818. /**
  41819. * Detailled logging while loading
  41820. */
  41821. static readonly DETAILED_LOGGING: number;
  41822. /**
  41823. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41824. */
  41825. static ForceFullSceneLoadingForIncremental: boolean;
  41826. /**
  41827. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41828. */
  41829. static ShowLoadingScreen: boolean;
  41830. /**
  41831. * Defines the current logging level (while loading the scene)
  41832. * @ignorenaming
  41833. */
  41834. static loggingLevel: number;
  41835. /**
  41836. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41837. */
  41838. static CleanBoneMatrixWeights: boolean;
  41839. /**
  41840. * Event raised when a plugin is used to load a scene
  41841. */
  41842. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41843. private static _registeredPlugins;
  41844. private static _getDefaultPlugin;
  41845. private static _getPluginForExtension;
  41846. private static _getPluginForDirectLoad;
  41847. private static _getPluginForFilename;
  41848. private static _getDirectLoad;
  41849. private static _loadData;
  41850. private static _getFileInfo;
  41851. /**
  41852. * Gets a plugin that can load the given extension
  41853. * @param extension defines the extension to load
  41854. * @returns a plugin or null if none works
  41855. */
  41856. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41857. /**
  41858. * Gets a boolean indicating that the given extension can be loaded
  41859. * @param extension defines the extension to load
  41860. * @returns true if the extension is supported
  41861. */
  41862. static IsPluginForExtensionAvailable(extension: string): boolean;
  41863. /**
  41864. * Adds a new plugin to the list of registered plugins
  41865. * @param plugin defines the plugin to add
  41866. */
  41867. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41868. /**
  41869. * Import meshes into a scene
  41870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41871. * @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)
  41872. * @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)
  41873. * @param scene the instance of BABYLON.Scene to append to
  41874. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41875. * @param onProgress a callback with a progress event for each file being loaded
  41876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41877. * @param pluginExtension the extension used to determine the plugin
  41878. * @returns The loaded plugin
  41879. */
  41880. 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>;
  41881. /**
  41882. * Import meshes into a scene
  41883. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41884. * @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)
  41885. * @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)
  41886. * @param scene the instance of BABYLON.Scene to append to
  41887. * @param onProgress a callback with a progress event for each file being loaded
  41888. * @param pluginExtension the extension used to determine the plugin
  41889. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41890. */
  41891. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41892. meshes: AbstractMesh[];
  41893. particleSystems: IParticleSystem[];
  41894. skeletons: Skeleton[];
  41895. animationGroups: AnimationGroup[];
  41896. }>;
  41897. /**
  41898. * Load a scene
  41899. * @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)
  41900. * @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)
  41901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41902. * @param onSuccess a callback with the scene when import succeeds
  41903. * @param onProgress a callback with a progress event for each file being loaded
  41904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41905. * @param pluginExtension the extension used to determine the plugin
  41906. * @returns The loaded plugin
  41907. */
  41908. 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>;
  41909. /**
  41910. * Load a scene
  41911. * @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)
  41912. * @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)
  41913. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41914. * @param onProgress a callback with a progress event for each file being loaded
  41915. * @param pluginExtension the extension used to determine the plugin
  41916. * @returns The loaded scene
  41917. */
  41918. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41919. /**
  41920. * Append a scene
  41921. * @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)
  41922. * @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)
  41923. * @param scene is the instance of BABYLON.Scene to append to
  41924. * @param onSuccess a callback with the scene when import succeeds
  41925. * @param onProgress a callback with a progress event for each file being loaded
  41926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41927. * @param pluginExtension the extension used to determine the plugin
  41928. * @returns The loaded plugin
  41929. */
  41930. 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>;
  41931. /**
  41932. * Append a scene
  41933. * @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)
  41934. * @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)
  41935. * @param scene is the instance of BABYLON.Scene to append to
  41936. * @param onProgress a callback with a progress event for each file being loaded
  41937. * @param pluginExtension the extension used to determine the plugin
  41938. * @returns The given scene
  41939. */
  41940. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41941. /**
  41942. * Load a scene into an asset container
  41943. * @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)
  41944. * @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)
  41945. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41946. * @param onSuccess a callback with the scene when import succeeds
  41947. * @param onProgress a callback with a progress event for each file being loaded
  41948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41949. * @param pluginExtension the extension used to determine the plugin
  41950. * @returns The loaded plugin
  41951. */
  41952. 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>;
  41953. /**
  41954. * Load a scene into an asset container
  41955. * @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)
  41956. * @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)
  41957. * @param scene is the instance of Scene to append to
  41958. * @param onProgress a callback with a progress event for each file being loaded
  41959. * @param pluginExtension the extension used to determine the plugin
  41960. * @returns The loaded asset container
  41961. */
  41962. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41963. }
  41964. }
  41965. declare module BABYLON {
  41966. /**
  41967. * Generic Controller
  41968. */
  41969. export class GenericController extends WebVRController {
  41970. /**
  41971. * Base Url for the controller model.
  41972. */
  41973. static readonly MODEL_BASE_URL: string;
  41974. /**
  41975. * File name for the controller model.
  41976. */
  41977. static readonly MODEL_FILENAME: string;
  41978. /**
  41979. * Creates a new GenericController from a gamepad
  41980. * @param vrGamepad the gamepad that the controller should be created from
  41981. */
  41982. constructor(vrGamepad: any);
  41983. /**
  41984. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41985. * @param scene scene in which to add meshes
  41986. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41987. */
  41988. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41989. /**
  41990. * Called once for each button that changed state since the last frame
  41991. * @param buttonIdx Which button index changed
  41992. * @param state New state of the button
  41993. * @param changes Which properties on the state changed since last frame
  41994. */
  41995. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Defines the WindowsMotionController object that the state of the windows motion controller
  42001. */
  42002. export class WindowsMotionController extends WebVRController {
  42003. /**
  42004. * The base url used to load the left and right controller models
  42005. */
  42006. static MODEL_BASE_URL: string;
  42007. /**
  42008. * The name of the left controller model file
  42009. */
  42010. static MODEL_LEFT_FILENAME: string;
  42011. /**
  42012. * The name of the right controller model file
  42013. */
  42014. static MODEL_RIGHT_FILENAME: string;
  42015. /**
  42016. * The controller name prefix for this controller type
  42017. */
  42018. static readonly GAMEPAD_ID_PREFIX: string;
  42019. /**
  42020. * The controller id pattern for this controller type
  42021. */
  42022. private static readonly GAMEPAD_ID_PATTERN;
  42023. private _loadedMeshInfo;
  42024. private readonly _mapping;
  42025. /**
  42026. * Fired when the trackpad on this controller is clicked
  42027. */
  42028. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42029. /**
  42030. * Fired when the trackpad on this controller is modified
  42031. */
  42032. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42033. /**
  42034. * The current x and y values of this controller's trackpad
  42035. */
  42036. trackpad: StickValues;
  42037. /**
  42038. * Creates a new WindowsMotionController from a gamepad
  42039. * @param vrGamepad the gamepad that the controller should be created from
  42040. */
  42041. constructor(vrGamepad: any);
  42042. /**
  42043. * Fired when the trigger on this controller is modified
  42044. */
  42045. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42046. /**
  42047. * Fired when the menu button on this controller is modified
  42048. */
  42049. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42050. /**
  42051. * Fired when the grip button on this controller is modified
  42052. */
  42053. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42054. /**
  42055. * Fired when the thumbstick button on this controller is modified
  42056. */
  42057. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42058. /**
  42059. * Fired when the touchpad button on this controller is modified
  42060. */
  42061. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42062. /**
  42063. * Fired when the touchpad values on this controller are modified
  42064. */
  42065. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42066. private _updateTrackpad;
  42067. /**
  42068. * Called once per frame by the engine.
  42069. */
  42070. update(): void;
  42071. /**
  42072. * Called once for each button that changed state since the last frame
  42073. * @param buttonIdx Which button index changed
  42074. * @param state New state of the button
  42075. * @param changes Which properties on the state changed since last frame
  42076. */
  42077. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42078. /**
  42079. * Moves the buttons on the controller mesh based on their current state
  42080. * @param buttonName the name of the button to move
  42081. * @param buttonValue the value of the button which determines the buttons new position
  42082. */
  42083. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42084. /**
  42085. * Moves the axis on the controller mesh based on its current state
  42086. * @param axis the index of the axis
  42087. * @param axisValue the value of the axis which determines the meshes new position
  42088. * @hidden
  42089. */
  42090. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42091. /**
  42092. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42093. * @param scene scene in which to add meshes
  42094. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42095. */
  42096. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42097. /**
  42098. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42099. * can be transformed by button presses and axes values, based on this._mapping.
  42100. *
  42101. * @param scene scene in which the meshes exist
  42102. * @param meshes list of meshes that make up the controller model to process
  42103. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42104. */
  42105. private processModel;
  42106. private createMeshInfo;
  42107. /**
  42108. * Gets the ray of the controller in the direction the controller is pointing
  42109. * @param length the length the resulting ray should be
  42110. * @returns a ray in the direction the controller is pointing
  42111. */
  42112. getForwardRay(length?: number): Ray;
  42113. /**
  42114. * Disposes of the controller
  42115. */
  42116. dispose(): void;
  42117. }
  42118. }
  42119. declare module BABYLON {
  42120. /**
  42121. * Oculus Touch Controller
  42122. */
  42123. export class OculusTouchController extends WebVRController {
  42124. /**
  42125. * Base Url for the controller model.
  42126. */
  42127. static MODEL_BASE_URL: string;
  42128. /**
  42129. * File name for the left controller model.
  42130. */
  42131. static MODEL_LEFT_FILENAME: string;
  42132. /**
  42133. * File name for the right controller model.
  42134. */
  42135. static MODEL_RIGHT_FILENAME: string;
  42136. /**
  42137. * Base Url for the Quest controller model.
  42138. */
  42139. static QUEST_MODEL_BASE_URL: string;
  42140. /**
  42141. * @hidden
  42142. * If the controllers are running on a device that needs the updated Quest controller models
  42143. */
  42144. static _IsQuest: boolean;
  42145. /**
  42146. * Fired when the secondary trigger on this controller is modified
  42147. */
  42148. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42149. /**
  42150. * Fired when the thumb rest on this controller is modified
  42151. */
  42152. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42153. /**
  42154. * Creates a new OculusTouchController from a gamepad
  42155. * @param vrGamepad the gamepad that the controller should be created from
  42156. */
  42157. constructor(vrGamepad: any);
  42158. /**
  42159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42160. * @param scene scene in which to add meshes
  42161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42162. */
  42163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42164. /**
  42165. * Fired when the A button on this controller is modified
  42166. */
  42167. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42168. /**
  42169. * Fired when the B button on this controller is modified
  42170. */
  42171. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42172. /**
  42173. * Fired when the X button on this controller is modified
  42174. */
  42175. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42176. /**
  42177. * Fired when the Y button on this controller is modified
  42178. */
  42179. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42180. /**
  42181. * Called once for each button that changed state since the last frame
  42182. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42183. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42184. * 2) secondary trigger (same)
  42185. * 3) A (right) X (left), touch, pressed = value
  42186. * 4) B / Y
  42187. * 5) thumb rest
  42188. * @param buttonIdx Which button index changed
  42189. * @param state New state of the button
  42190. * @param changes Which properties on the state changed since last frame
  42191. */
  42192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /**
  42197. * Vive Controller
  42198. */
  42199. export class ViveController extends WebVRController {
  42200. /**
  42201. * Base Url for the controller model.
  42202. */
  42203. static MODEL_BASE_URL: string;
  42204. /**
  42205. * File name for the controller model.
  42206. */
  42207. static MODEL_FILENAME: string;
  42208. /**
  42209. * Creates a new ViveController from a gamepad
  42210. * @param vrGamepad the gamepad that the controller should be created from
  42211. */
  42212. constructor(vrGamepad: any);
  42213. /**
  42214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42215. * @param scene scene in which to add meshes
  42216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42217. */
  42218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42219. /**
  42220. * Fired when the left button on this controller is modified
  42221. */
  42222. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42223. /**
  42224. * Fired when the right button on this controller is modified
  42225. */
  42226. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42227. /**
  42228. * Fired when the menu button on this controller is modified
  42229. */
  42230. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42231. /**
  42232. * Called once for each button that changed state since the last frame
  42233. * Vive mapping:
  42234. * 0: touchpad
  42235. * 1: trigger
  42236. * 2: left AND right buttons
  42237. * 3: menu button
  42238. * @param buttonIdx Which button index changed
  42239. * @param state New state of the button
  42240. * @param changes Which properties on the state changed since last frame
  42241. */
  42242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42243. }
  42244. }
  42245. declare module BABYLON {
  42246. /**
  42247. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42248. */
  42249. export class WebXRControllerModelLoader {
  42250. /**
  42251. * Creates the WebXRControllerModelLoader
  42252. * @param input xr input that creates the controllers
  42253. */
  42254. constructor(input: WebXRInput);
  42255. }
  42256. }
  42257. declare module BABYLON {
  42258. /**
  42259. * Contains an array of blocks representing the octree
  42260. */
  42261. export interface IOctreeContainer<T> {
  42262. /**
  42263. * Blocks within the octree
  42264. */
  42265. blocks: Array<OctreeBlock<T>>;
  42266. }
  42267. /**
  42268. * Class used to store a cell in an octree
  42269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42270. */
  42271. export class OctreeBlock<T> {
  42272. /**
  42273. * Gets the content of the current block
  42274. */
  42275. entries: T[];
  42276. /**
  42277. * Gets the list of block children
  42278. */
  42279. blocks: Array<OctreeBlock<T>>;
  42280. private _depth;
  42281. private _maxDepth;
  42282. private _capacity;
  42283. private _minPoint;
  42284. private _maxPoint;
  42285. private _boundingVectors;
  42286. private _creationFunc;
  42287. /**
  42288. * Creates a new block
  42289. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42290. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42291. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42292. * @param depth defines the current depth of this block in the octree
  42293. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42294. * @param creationFunc defines a callback to call when an element is added to the block
  42295. */
  42296. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42297. /**
  42298. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42299. */
  42300. readonly capacity: number;
  42301. /**
  42302. * Gets the minimum vector (in world space) of the block's bounding box
  42303. */
  42304. readonly minPoint: Vector3;
  42305. /**
  42306. * Gets the maximum vector (in world space) of the block's bounding box
  42307. */
  42308. readonly maxPoint: Vector3;
  42309. /**
  42310. * Add a new element to this block
  42311. * @param entry defines the element to add
  42312. */
  42313. addEntry(entry: T): void;
  42314. /**
  42315. * Remove an element from this block
  42316. * @param entry defines the element to remove
  42317. */
  42318. removeEntry(entry: T): void;
  42319. /**
  42320. * Add an array of elements to this block
  42321. * @param entries defines the array of elements to add
  42322. */
  42323. addEntries(entries: T[]): void;
  42324. /**
  42325. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42326. * @param frustumPlanes defines the frustum planes to test
  42327. * @param selection defines the array to store current content if selection is positive
  42328. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42329. */
  42330. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42331. /**
  42332. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42333. * @param sphereCenter defines the bounding sphere center
  42334. * @param sphereRadius defines the bounding sphere radius
  42335. * @param selection defines the array to store current content if selection is positive
  42336. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42337. */
  42338. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42339. /**
  42340. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42341. * @param ray defines the ray to test with
  42342. * @param selection defines the array to store current content if selection is positive
  42343. */
  42344. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42345. /**
  42346. * Subdivide the content into child blocks (this block will then be empty)
  42347. */
  42348. createInnerBlocks(): void;
  42349. /**
  42350. * @hidden
  42351. */
  42352. 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;
  42353. }
  42354. }
  42355. declare module BABYLON {
  42356. /**
  42357. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42359. */
  42360. export class Octree<T> {
  42361. /** 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.) */
  42362. maxDepth: number;
  42363. /**
  42364. * Blocks within the octree containing objects
  42365. */
  42366. blocks: Array<OctreeBlock<T>>;
  42367. /**
  42368. * Content stored in the octree
  42369. */
  42370. dynamicContent: T[];
  42371. private _maxBlockCapacity;
  42372. private _selectionContent;
  42373. private _creationFunc;
  42374. /**
  42375. * Creates a octree
  42376. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42377. * @param creationFunc function to be used to instatiate the octree
  42378. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42379. * @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.)
  42380. */
  42381. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42382. /** 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.) */
  42383. maxDepth?: number);
  42384. /**
  42385. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42386. * @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);
  42387. * @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);
  42388. * @param entries meshes to be added to the octree blocks
  42389. */
  42390. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42391. /**
  42392. * Adds a mesh to the octree
  42393. * @param entry Mesh to add to the octree
  42394. */
  42395. addMesh(entry: T): void;
  42396. /**
  42397. * Remove an element from the octree
  42398. * @param entry defines the element to remove
  42399. */
  42400. removeMesh(entry: T): void;
  42401. /**
  42402. * Selects an array of meshes within the frustum
  42403. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42404. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42405. * @returns array of meshes within the frustum
  42406. */
  42407. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42408. /**
  42409. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42410. * @param sphereCenter defines the bounding sphere center
  42411. * @param sphereRadius defines the bounding sphere radius
  42412. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42413. * @returns an array of objects that intersect the sphere
  42414. */
  42415. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42416. /**
  42417. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42418. * @param ray defines the ray to test with
  42419. * @returns array of intersected objects
  42420. */
  42421. intersectsRay(ray: Ray): SmartArray<T>;
  42422. /**
  42423. * Adds a mesh into the octree block if it intersects the block
  42424. */
  42425. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42426. /**
  42427. * Adds a submesh into the octree block if it intersects the block
  42428. */
  42429. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42430. }
  42431. }
  42432. declare module BABYLON {
  42433. interface Scene {
  42434. /**
  42435. * @hidden
  42436. * Backing Filed
  42437. */
  42438. _selectionOctree: Octree<AbstractMesh>;
  42439. /**
  42440. * Gets the octree used to boost mesh selection (picking)
  42441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42442. */
  42443. selectionOctree: Octree<AbstractMesh>;
  42444. /**
  42445. * Creates or updates the octree used to boost selection (picking)
  42446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42447. * @param maxCapacity defines the maximum capacity per leaf
  42448. * @param maxDepth defines the maximum depth of the octree
  42449. * @returns an octree of AbstractMesh
  42450. */
  42451. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42452. }
  42453. interface AbstractMesh {
  42454. /**
  42455. * @hidden
  42456. * Backing Field
  42457. */
  42458. _submeshesOctree: Octree<SubMesh>;
  42459. /**
  42460. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42461. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42462. * @param maxCapacity defines the maximum size of each block (64 by default)
  42463. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42464. * @returns the new octree
  42465. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42467. */
  42468. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42469. }
  42470. /**
  42471. * Defines the octree scene component responsible to manage any octrees
  42472. * in a given scene.
  42473. */
  42474. export class OctreeSceneComponent {
  42475. /**
  42476. * The component name help to identify the component in the list of scene components.
  42477. */
  42478. readonly name: string;
  42479. /**
  42480. * The scene the component belongs to.
  42481. */
  42482. scene: Scene;
  42483. /**
  42484. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42485. */
  42486. readonly checksIsEnabled: boolean;
  42487. /**
  42488. * Creates a new instance of the component for the given scene
  42489. * @param scene Defines the scene to register the component in
  42490. */
  42491. constructor(scene: Scene);
  42492. /**
  42493. * Registers the component in a given scene
  42494. */
  42495. register(): void;
  42496. /**
  42497. * Return the list of active meshes
  42498. * @returns the list of active meshes
  42499. */
  42500. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42501. /**
  42502. * Return the list of active sub meshes
  42503. * @param mesh The mesh to get the candidates sub meshes from
  42504. * @returns the list of active sub meshes
  42505. */
  42506. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42507. private _tempRay;
  42508. /**
  42509. * Return the list of sub meshes intersecting with a given local ray
  42510. * @param mesh defines the mesh to find the submesh for
  42511. * @param localRay defines the ray in local space
  42512. * @returns the list of intersecting sub meshes
  42513. */
  42514. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42515. /**
  42516. * Return the list of sub meshes colliding with a collider
  42517. * @param mesh defines the mesh to find the submesh for
  42518. * @param collider defines the collider to evaluate the collision against
  42519. * @returns the list of colliding sub meshes
  42520. */
  42521. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42522. /**
  42523. * Rebuilds the elements related to this component in case of
  42524. * context lost for instance.
  42525. */
  42526. rebuild(): void;
  42527. /**
  42528. * Disposes the component and the associated ressources.
  42529. */
  42530. dispose(): void;
  42531. }
  42532. }
  42533. declare module BABYLON {
  42534. /**
  42535. * Renders a layer on top of an existing scene
  42536. */
  42537. export class UtilityLayerRenderer implements IDisposable {
  42538. /** the original scene that will be rendered on top of */
  42539. originalScene: Scene;
  42540. private _pointerCaptures;
  42541. private _lastPointerEvents;
  42542. private static _DefaultUtilityLayer;
  42543. private static _DefaultKeepDepthUtilityLayer;
  42544. private _sharedGizmoLight;
  42545. private _renderCamera;
  42546. /**
  42547. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42548. * @returns the camera that is used when rendering the utility layer
  42549. */
  42550. getRenderCamera(): Nullable<Camera>;
  42551. /**
  42552. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42553. * @param cam the camera that should be used when rendering the utility layer
  42554. */
  42555. setRenderCamera(cam: Nullable<Camera>): void;
  42556. /**
  42557. * @hidden
  42558. * Light which used by gizmos to get light shading
  42559. */
  42560. _getSharedGizmoLight(): HemisphericLight;
  42561. /**
  42562. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42563. */
  42564. pickUtilitySceneFirst: boolean;
  42565. /**
  42566. * 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)
  42567. */
  42568. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42569. /**
  42570. * 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)
  42571. */
  42572. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42573. /**
  42574. * The scene that is rendered on top of the original scene
  42575. */
  42576. utilityLayerScene: Scene;
  42577. /**
  42578. * If the utility layer should automatically be rendered on top of existing scene
  42579. */
  42580. shouldRender: boolean;
  42581. /**
  42582. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42583. */
  42584. onlyCheckPointerDownEvents: boolean;
  42585. /**
  42586. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42587. */
  42588. processAllEvents: boolean;
  42589. /**
  42590. * Observable raised when the pointer move from the utility layer scene to the main scene
  42591. */
  42592. onPointerOutObservable: Observable<number>;
  42593. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42594. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42595. private _afterRenderObserver;
  42596. private _sceneDisposeObserver;
  42597. private _originalPointerObserver;
  42598. /**
  42599. * Instantiates a UtilityLayerRenderer
  42600. * @param originalScene the original scene that will be rendered on top of
  42601. * @param handleEvents boolean indicating if the utility layer should handle events
  42602. */
  42603. constructor(
  42604. /** the original scene that will be rendered on top of */
  42605. originalScene: Scene, handleEvents?: boolean);
  42606. private _notifyObservers;
  42607. /**
  42608. * Renders the utility layers scene on top of the original scene
  42609. */
  42610. render(): void;
  42611. /**
  42612. * Disposes of the renderer
  42613. */
  42614. dispose(): void;
  42615. private _updateCamera;
  42616. }
  42617. }
  42618. declare module BABYLON {
  42619. /**
  42620. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42621. */
  42622. export class Gizmo implements IDisposable {
  42623. /** The utility layer the gizmo will be added to */
  42624. gizmoLayer: UtilityLayerRenderer;
  42625. /**
  42626. * The root mesh of the gizmo
  42627. */
  42628. _rootMesh: Mesh;
  42629. private _attachedMesh;
  42630. /**
  42631. * Ratio for the scale of the gizmo (Default: 1)
  42632. */
  42633. scaleRatio: number;
  42634. /**
  42635. * If a custom mesh has been set (Default: false)
  42636. */
  42637. protected _customMeshSet: boolean;
  42638. /**
  42639. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42640. * * When set, interactions will be enabled
  42641. */
  42642. attachedMesh: Nullable<AbstractMesh>;
  42643. /**
  42644. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42645. * @param mesh The mesh to replace the default mesh of the gizmo
  42646. */
  42647. setCustomMesh(mesh: Mesh): void;
  42648. /**
  42649. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42650. */
  42651. updateGizmoRotationToMatchAttachedMesh: boolean;
  42652. /**
  42653. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42654. */
  42655. updateGizmoPositionToMatchAttachedMesh: boolean;
  42656. /**
  42657. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42658. */
  42659. updateScale: boolean;
  42660. protected _interactionsEnabled: boolean;
  42661. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42662. private _beforeRenderObserver;
  42663. private _tempVector;
  42664. /**
  42665. * Creates a gizmo
  42666. * @param gizmoLayer The utility layer the gizmo will be added to
  42667. */
  42668. constructor(
  42669. /** The utility layer the gizmo will be added to */
  42670. gizmoLayer?: UtilityLayerRenderer);
  42671. /**
  42672. * Updates the gizmo to match the attached mesh's position/rotation
  42673. */
  42674. protected _update(): void;
  42675. /**
  42676. * Disposes of the gizmo
  42677. */
  42678. dispose(): void;
  42679. }
  42680. }
  42681. declare module BABYLON {
  42682. /**
  42683. * Single plane drag gizmo
  42684. */
  42685. export class PlaneDragGizmo extends Gizmo {
  42686. /**
  42687. * Drag behavior responsible for the gizmos dragging interactions
  42688. */
  42689. dragBehavior: PointerDragBehavior;
  42690. private _pointerObserver;
  42691. /**
  42692. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42693. */
  42694. snapDistance: number;
  42695. /**
  42696. * Event that fires each time the gizmo snaps to a new location.
  42697. * * snapDistance is the the change in distance
  42698. */
  42699. onSnapObservable: Observable<{
  42700. snapDistance: number;
  42701. }>;
  42702. private _plane;
  42703. private _coloredMaterial;
  42704. private _hoverMaterial;
  42705. private _isEnabled;
  42706. private _parent;
  42707. /** @hidden */
  42708. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42709. /** @hidden */
  42710. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42711. /**
  42712. * Creates a PlaneDragGizmo
  42713. * @param gizmoLayer The utility layer the gizmo will be added to
  42714. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42715. * @param color The color of the gizmo
  42716. */
  42717. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42718. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42719. /**
  42720. * If the gizmo is enabled
  42721. */
  42722. isEnabled: boolean;
  42723. /**
  42724. * Disposes of the gizmo
  42725. */
  42726. dispose(): void;
  42727. }
  42728. }
  42729. declare module BABYLON {
  42730. /**
  42731. * Gizmo that enables dragging a mesh along 3 axis
  42732. */
  42733. export class PositionGizmo extends Gizmo {
  42734. /**
  42735. * Internal gizmo used for interactions on the x axis
  42736. */
  42737. xGizmo: AxisDragGizmo;
  42738. /**
  42739. * Internal gizmo used for interactions on the y axis
  42740. */
  42741. yGizmo: AxisDragGizmo;
  42742. /**
  42743. * Internal gizmo used for interactions on the z axis
  42744. */
  42745. zGizmo: AxisDragGizmo;
  42746. /**
  42747. * Internal gizmo used for interactions on the yz plane
  42748. */
  42749. xPlaneGizmo: PlaneDragGizmo;
  42750. /**
  42751. * Internal gizmo used for interactions on the xz plane
  42752. */
  42753. yPlaneGizmo: PlaneDragGizmo;
  42754. /**
  42755. * Internal gizmo used for interactions on the xy plane
  42756. */
  42757. zPlaneGizmo: PlaneDragGizmo;
  42758. /**
  42759. * private variables
  42760. */
  42761. private _meshAttached;
  42762. private _updateGizmoRotationToMatchAttachedMesh;
  42763. private _snapDistance;
  42764. private _scaleRatio;
  42765. /** Fires an event when any of it's sub gizmos are dragged */
  42766. onDragStartObservable: Observable<unknown>;
  42767. /** Fires an event when any of it's sub gizmos are released from dragging */
  42768. onDragEndObservable: Observable<unknown>;
  42769. /**
  42770. * If set to true, planar drag is enabled
  42771. */
  42772. private _planarGizmoEnabled;
  42773. attachedMesh: Nullable<AbstractMesh>;
  42774. /**
  42775. * Creates a PositionGizmo
  42776. * @param gizmoLayer The utility layer the gizmo will be added to
  42777. */
  42778. constructor(gizmoLayer?: UtilityLayerRenderer);
  42779. /**
  42780. * If the planar drag gizmo is enabled
  42781. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42782. */
  42783. planarGizmoEnabled: boolean;
  42784. updateGizmoRotationToMatchAttachedMesh: boolean;
  42785. /**
  42786. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42787. */
  42788. snapDistance: number;
  42789. /**
  42790. * Ratio for the scale of the gizmo (Default: 1)
  42791. */
  42792. scaleRatio: number;
  42793. /**
  42794. * Disposes of the gizmo
  42795. */
  42796. dispose(): void;
  42797. /**
  42798. * CustomMeshes are not supported by this gizmo
  42799. * @param mesh The mesh to replace the default mesh of the gizmo
  42800. */
  42801. setCustomMesh(mesh: Mesh): void;
  42802. }
  42803. }
  42804. declare module BABYLON {
  42805. /**
  42806. * Single axis drag gizmo
  42807. */
  42808. export class AxisDragGizmo extends Gizmo {
  42809. /**
  42810. * Drag behavior responsible for the gizmos dragging interactions
  42811. */
  42812. dragBehavior: PointerDragBehavior;
  42813. private _pointerObserver;
  42814. /**
  42815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42816. */
  42817. snapDistance: number;
  42818. /**
  42819. * Event that fires each time the gizmo snaps to a new location.
  42820. * * snapDistance is the the change in distance
  42821. */
  42822. onSnapObservable: Observable<{
  42823. snapDistance: number;
  42824. }>;
  42825. private _isEnabled;
  42826. private _parent;
  42827. private _arrow;
  42828. private _coloredMaterial;
  42829. private _hoverMaterial;
  42830. /** @hidden */
  42831. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42832. /** @hidden */
  42833. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42834. /**
  42835. * Creates an AxisDragGizmo
  42836. * @param gizmoLayer The utility layer the gizmo will be added to
  42837. * @param dragAxis The axis which the gizmo will be able to drag on
  42838. * @param color The color of the gizmo
  42839. */
  42840. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42841. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42842. /**
  42843. * If the gizmo is enabled
  42844. */
  42845. isEnabled: boolean;
  42846. /**
  42847. * Disposes of the gizmo
  42848. */
  42849. dispose(): void;
  42850. }
  42851. }
  42852. declare module BABYLON.Debug {
  42853. /**
  42854. * The Axes viewer will show 3 axes in a specific point in space
  42855. */
  42856. export class AxesViewer {
  42857. private _xAxis;
  42858. private _yAxis;
  42859. private _zAxis;
  42860. private _scaleLinesFactor;
  42861. private _instanced;
  42862. /**
  42863. * Gets the hosting scene
  42864. */
  42865. scene: Scene;
  42866. /**
  42867. * Gets or sets a number used to scale line length
  42868. */
  42869. scaleLines: number;
  42870. /** Gets the node hierarchy used to render x-axis */
  42871. readonly xAxis: TransformNode;
  42872. /** Gets the node hierarchy used to render y-axis */
  42873. readonly yAxis: TransformNode;
  42874. /** Gets the node hierarchy used to render z-axis */
  42875. readonly zAxis: TransformNode;
  42876. /**
  42877. * Creates a new AxesViewer
  42878. * @param scene defines the hosting scene
  42879. * @param scaleLines defines a number used to scale line length (1 by default)
  42880. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42881. * @param xAxis defines the node hierarchy used to render the x-axis
  42882. * @param yAxis defines the node hierarchy used to render the y-axis
  42883. * @param zAxis defines the node hierarchy used to render the z-axis
  42884. */
  42885. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42886. /**
  42887. * Force the viewer to update
  42888. * @param position defines the position of the viewer
  42889. * @param xaxis defines the x axis of the viewer
  42890. * @param yaxis defines the y axis of the viewer
  42891. * @param zaxis defines the z axis of the viewer
  42892. */
  42893. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42894. /**
  42895. * Creates an instance of this axes viewer.
  42896. * @returns a new axes viewer with instanced meshes
  42897. */
  42898. createInstance(): AxesViewer;
  42899. /** Releases resources */
  42900. dispose(): void;
  42901. private static _SetRenderingGroupId;
  42902. }
  42903. }
  42904. declare module BABYLON.Debug {
  42905. /**
  42906. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42907. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42908. */
  42909. export class BoneAxesViewer extends AxesViewer {
  42910. /**
  42911. * Gets or sets the target mesh where to display the axes viewer
  42912. */
  42913. mesh: Nullable<Mesh>;
  42914. /**
  42915. * Gets or sets the target bone where to display the axes viewer
  42916. */
  42917. bone: Nullable<Bone>;
  42918. /** Gets current position */
  42919. pos: Vector3;
  42920. /** Gets direction of X axis */
  42921. xaxis: Vector3;
  42922. /** Gets direction of Y axis */
  42923. yaxis: Vector3;
  42924. /** Gets direction of Z axis */
  42925. zaxis: Vector3;
  42926. /**
  42927. * Creates a new BoneAxesViewer
  42928. * @param scene defines the hosting scene
  42929. * @param bone defines the target bone
  42930. * @param mesh defines the target mesh
  42931. * @param scaleLines defines a scaling factor for line length (1 by default)
  42932. */
  42933. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42934. /**
  42935. * Force the viewer to update
  42936. */
  42937. update(): void;
  42938. /** Releases resources */
  42939. dispose(): void;
  42940. }
  42941. }
  42942. declare module BABYLON {
  42943. /**
  42944. * Interface used to define scene explorer extensibility option
  42945. */
  42946. export interface IExplorerExtensibilityOption {
  42947. /**
  42948. * Define the option label
  42949. */
  42950. label: string;
  42951. /**
  42952. * Defines the action to execute on click
  42953. */
  42954. action: (entity: any) => void;
  42955. }
  42956. /**
  42957. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42958. */
  42959. export interface IExplorerExtensibilityGroup {
  42960. /**
  42961. * Defines a predicate to test if a given type mut be extended
  42962. */
  42963. predicate: (entity: any) => boolean;
  42964. /**
  42965. * Gets the list of options added to a type
  42966. */
  42967. entries: IExplorerExtensibilityOption[];
  42968. }
  42969. /**
  42970. * Interface used to define the options to use to create the Inspector
  42971. */
  42972. export interface IInspectorOptions {
  42973. /**
  42974. * Display in overlay mode (default: false)
  42975. */
  42976. overlay?: boolean;
  42977. /**
  42978. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42979. */
  42980. globalRoot?: HTMLElement;
  42981. /**
  42982. * Display the Scene explorer
  42983. */
  42984. showExplorer?: boolean;
  42985. /**
  42986. * Display the property inspector
  42987. */
  42988. showInspector?: boolean;
  42989. /**
  42990. * Display in embed mode (both panes on the right)
  42991. */
  42992. embedMode?: boolean;
  42993. /**
  42994. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42995. */
  42996. handleResize?: boolean;
  42997. /**
  42998. * Allow the panes to popup (default: true)
  42999. */
  43000. enablePopup?: boolean;
  43001. /**
  43002. * Allow the panes to be closed by users (default: true)
  43003. */
  43004. enableClose?: boolean;
  43005. /**
  43006. * Optional list of extensibility entries
  43007. */
  43008. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43009. /**
  43010. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43011. */
  43012. inspectorURL?: string;
  43013. }
  43014. interface Scene {
  43015. /**
  43016. * @hidden
  43017. * Backing field
  43018. */
  43019. _debugLayer: DebugLayer;
  43020. /**
  43021. * Gets the debug layer (aka Inspector) associated with the scene
  43022. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43023. */
  43024. debugLayer: DebugLayer;
  43025. }
  43026. /**
  43027. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43028. * what is happening in your scene
  43029. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43030. */
  43031. export class DebugLayer {
  43032. /**
  43033. * Define the url to get the inspector script from.
  43034. * By default it uses the babylonjs CDN.
  43035. * @ignoreNaming
  43036. */
  43037. static InspectorURL: string;
  43038. private _scene;
  43039. private BJSINSPECTOR;
  43040. private _onPropertyChangedObservable?;
  43041. /**
  43042. * Observable triggered when a property is changed through the inspector.
  43043. */
  43044. readonly onPropertyChangedObservable: any;
  43045. /**
  43046. * Instantiates a new debug layer.
  43047. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43048. * what is happening in your scene
  43049. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43050. * @param scene Defines the scene to inspect
  43051. */
  43052. constructor(scene: Scene);
  43053. /** Creates the inspector window. */
  43054. private _createInspector;
  43055. /**
  43056. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43057. * @param entity defines the entity to select
  43058. * @param lineContainerTitle defines the specific block to highlight
  43059. */
  43060. select(entity: any, lineContainerTitle?: string): void;
  43061. /** Get the inspector from bundle or global */
  43062. private _getGlobalInspector;
  43063. /**
  43064. * Get if the inspector is visible or not.
  43065. * @returns true if visible otherwise, false
  43066. */
  43067. isVisible(): boolean;
  43068. /**
  43069. * Hide the inspector and close its window.
  43070. */
  43071. hide(): void;
  43072. /**
  43073. * Launch the debugLayer.
  43074. * @param config Define the configuration of the inspector
  43075. * @return a promise fulfilled when the debug layer is visible
  43076. */
  43077. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43078. }
  43079. }
  43080. declare module BABYLON {
  43081. /**
  43082. * Class containing static functions to help procedurally build meshes
  43083. */
  43084. export class BoxBuilder {
  43085. /**
  43086. * Creates a box mesh
  43087. * * The parameter `size` sets the size (float) of each box side (default 1)
  43088. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43089. * * 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)
  43090. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43092. * * 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
  43093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43094. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43095. * @param name defines the name of the mesh
  43096. * @param options defines the options used to create the mesh
  43097. * @param scene defines the hosting scene
  43098. * @returns the box mesh
  43099. */
  43100. static CreateBox(name: string, options: {
  43101. size?: number;
  43102. width?: number;
  43103. height?: number;
  43104. depth?: number;
  43105. faceUV?: Vector4[];
  43106. faceColors?: Color4[];
  43107. sideOrientation?: number;
  43108. frontUVs?: Vector4;
  43109. backUVs?: Vector4;
  43110. wrap?: boolean;
  43111. topBaseAt?: number;
  43112. bottomBaseAt?: number;
  43113. updatable?: boolean;
  43114. }, scene?: Nullable<Scene>): Mesh;
  43115. }
  43116. }
  43117. declare module BABYLON {
  43118. /**
  43119. * Class containing static functions to help procedurally build meshes
  43120. */
  43121. export class SphereBuilder {
  43122. /**
  43123. * Creates a sphere mesh
  43124. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43125. * * 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`)
  43126. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43127. * * 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
  43128. * * 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)
  43129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43130. * * 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
  43131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43132. * @param name defines the name of the mesh
  43133. * @param options defines the options used to create the mesh
  43134. * @param scene defines the hosting scene
  43135. * @returns the sphere mesh
  43136. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43137. */
  43138. static CreateSphere(name: string, options: {
  43139. segments?: number;
  43140. diameter?: number;
  43141. diameterX?: number;
  43142. diameterY?: number;
  43143. diameterZ?: number;
  43144. arc?: number;
  43145. slice?: number;
  43146. sideOrientation?: number;
  43147. frontUVs?: Vector4;
  43148. backUVs?: Vector4;
  43149. updatable?: boolean;
  43150. }, scene?: Nullable<Scene>): Mesh;
  43151. }
  43152. }
  43153. declare module BABYLON.Debug {
  43154. /**
  43155. * Used to show the physics impostor around the specific mesh
  43156. */
  43157. export class PhysicsViewer {
  43158. /** @hidden */
  43159. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43160. /** @hidden */
  43161. protected _meshes: Array<Nullable<AbstractMesh>>;
  43162. /** @hidden */
  43163. protected _scene: Nullable<Scene>;
  43164. /** @hidden */
  43165. protected _numMeshes: number;
  43166. /** @hidden */
  43167. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43168. private _renderFunction;
  43169. private _utilityLayer;
  43170. private _debugBoxMesh;
  43171. private _debugSphereMesh;
  43172. private _debugCylinderMesh;
  43173. private _debugMaterial;
  43174. private _debugMeshMeshes;
  43175. /**
  43176. * Creates a new PhysicsViewer
  43177. * @param scene defines the hosting scene
  43178. */
  43179. constructor(scene: Scene);
  43180. /** @hidden */
  43181. protected _updateDebugMeshes(): void;
  43182. /**
  43183. * Renders a specified physic impostor
  43184. * @param impostor defines the impostor to render
  43185. * @param targetMesh defines the mesh represented by the impostor
  43186. * @returns the new debug mesh used to render the impostor
  43187. */
  43188. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43189. /**
  43190. * Hides a specified physic impostor
  43191. * @param impostor defines the impostor to hide
  43192. */
  43193. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43194. private _getDebugMaterial;
  43195. private _getDebugBoxMesh;
  43196. private _getDebugSphereMesh;
  43197. private _getDebugCylinderMesh;
  43198. private _getDebugMeshMesh;
  43199. private _getDebugMesh;
  43200. /** Releases all resources */
  43201. dispose(): void;
  43202. }
  43203. }
  43204. declare module BABYLON {
  43205. /**
  43206. * Class containing static functions to help procedurally build meshes
  43207. */
  43208. export class LinesBuilder {
  43209. /**
  43210. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43211. * * 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
  43212. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43213. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43214. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43215. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43216. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43217. * * 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
  43218. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43221. * @param name defines the name of the new line system
  43222. * @param options defines the options used to create the line system
  43223. * @param scene defines the hosting scene
  43224. * @returns a new line system mesh
  43225. */
  43226. static CreateLineSystem(name: string, options: {
  43227. lines: Vector3[][];
  43228. updatable?: boolean;
  43229. instance?: Nullable<LinesMesh>;
  43230. colors?: Nullable<Color4[][]>;
  43231. useVertexAlpha?: boolean;
  43232. }, scene: Nullable<Scene>): LinesMesh;
  43233. /**
  43234. * Creates a line mesh
  43235. * 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
  43236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43237. * * The parameter `points` is an array successive Vector3
  43238. * * 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
  43239. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43241. * * When updating an instance, remember that only point positions can change, not the number of points
  43242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43244. * @param name defines the name of the new line system
  43245. * @param options defines the options used to create the line system
  43246. * @param scene defines the hosting scene
  43247. * @returns a new line mesh
  43248. */
  43249. static CreateLines(name: string, options: {
  43250. points: Vector3[];
  43251. updatable?: boolean;
  43252. instance?: Nullable<LinesMesh>;
  43253. colors?: Color4[];
  43254. useVertexAlpha?: boolean;
  43255. }, scene?: Nullable<Scene>): LinesMesh;
  43256. /**
  43257. * Creates a dashed line mesh
  43258. * * 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
  43259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43260. * * The parameter `points` is an array successive Vector3
  43261. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43262. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43263. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43264. * * 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
  43265. * * When updating an instance, remember that only point positions can change, not the number of points
  43266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43267. * @param name defines the name of the mesh
  43268. * @param options defines the options used to create the mesh
  43269. * @param scene defines the hosting scene
  43270. * @returns the dashed line mesh
  43271. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43272. */
  43273. static CreateDashedLines(name: string, options: {
  43274. points: Vector3[];
  43275. dashSize?: number;
  43276. gapSize?: number;
  43277. dashNb?: number;
  43278. updatable?: boolean;
  43279. instance?: LinesMesh;
  43280. }, scene?: Nullable<Scene>): LinesMesh;
  43281. }
  43282. }
  43283. declare module BABYLON {
  43284. /**
  43285. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43286. * in order to better appreciate the issue one might have.
  43287. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43288. */
  43289. export class RayHelper {
  43290. /**
  43291. * Defines the ray we are currently tryin to visualize.
  43292. */
  43293. ray: Nullable<Ray>;
  43294. private _renderPoints;
  43295. private _renderLine;
  43296. private _renderFunction;
  43297. private _scene;
  43298. private _updateToMeshFunction;
  43299. private _attachedToMesh;
  43300. private _meshSpaceDirection;
  43301. private _meshSpaceOrigin;
  43302. /**
  43303. * Helper function to create a colored helper in a scene in one line.
  43304. * @param ray Defines the ray we are currently tryin to visualize
  43305. * @param scene Defines the scene the ray is used in
  43306. * @param color Defines the color we want to see the ray in
  43307. * @returns The newly created ray helper.
  43308. */
  43309. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43310. /**
  43311. * Instantiate a new ray helper.
  43312. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43313. * in order to better appreciate the issue one might have.
  43314. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43315. * @param ray Defines the ray we are currently tryin to visualize
  43316. */
  43317. constructor(ray: Ray);
  43318. /**
  43319. * Shows the ray we are willing to debug.
  43320. * @param scene Defines the scene the ray needs to be rendered in
  43321. * @param color Defines the color the ray needs to be rendered in
  43322. */
  43323. show(scene: Scene, color?: Color3): void;
  43324. /**
  43325. * Hides the ray we are debugging.
  43326. */
  43327. hide(): void;
  43328. private _render;
  43329. /**
  43330. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43331. * @param mesh Defines the mesh we want the helper attached to
  43332. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43333. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43334. * @param length Defines the length of the ray
  43335. */
  43336. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43337. /**
  43338. * Detach the ray helper from the mesh it has previously been attached to.
  43339. */
  43340. detachFromMesh(): void;
  43341. private _updateToMesh;
  43342. /**
  43343. * Dispose the helper and release its associated resources.
  43344. */
  43345. dispose(): void;
  43346. }
  43347. }
  43348. declare module BABYLON.Debug {
  43349. /**
  43350. * Class used to render a debug view of a given skeleton
  43351. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43352. */
  43353. export class SkeletonViewer {
  43354. /** defines the skeleton to render */
  43355. skeleton: Skeleton;
  43356. /** defines the mesh attached to the skeleton */
  43357. mesh: AbstractMesh;
  43358. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43359. autoUpdateBonesMatrices: boolean;
  43360. /** defines the rendering group id to use with the viewer */
  43361. renderingGroupId: number;
  43362. /** Gets or sets the color used to render the skeleton */
  43363. color: Color3;
  43364. private _scene;
  43365. private _debugLines;
  43366. private _debugMesh;
  43367. private _isEnabled;
  43368. private _renderFunction;
  43369. private _utilityLayer;
  43370. /**
  43371. * Returns the mesh used to render the bones
  43372. */
  43373. readonly debugMesh: Nullable<LinesMesh>;
  43374. /**
  43375. * Creates a new SkeletonViewer
  43376. * @param skeleton defines the skeleton to render
  43377. * @param mesh defines the mesh attached to the skeleton
  43378. * @param scene defines the hosting scene
  43379. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43380. * @param renderingGroupId defines the rendering group id to use with the viewer
  43381. */
  43382. constructor(
  43383. /** defines the skeleton to render */
  43384. skeleton: Skeleton,
  43385. /** defines the mesh attached to the skeleton */
  43386. mesh: AbstractMesh, scene: Scene,
  43387. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43388. autoUpdateBonesMatrices?: boolean,
  43389. /** defines the rendering group id to use with the viewer */
  43390. renderingGroupId?: number);
  43391. /** Gets or sets a boolean indicating if the viewer is enabled */
  43392. isEnabled: boolean;
  43393. private _getBonePosition;
  43394. private _getLinesForBonesWithLength;
  43395. private _getLinesForBonesNoLength;
  43396. /** Update the viewer to sync with current skeleton state */
  43397. update(): void;
  43398. /** Release associated resources */
  43399. dispose(): void;
  43400. }
  43401. }
  43402. declare module BABYLON {
  43403. /**
  43404. * Options to create the null engine
  43405. */
  43406. export class NullEngineOptions {
  43407. /**
  43408. * Render width (Default: 512)
  43409. */
  43410. renderWidth: number;
  43411. /**
  43412. * Render height (Default: 256)
  43413. */
  43414. renderHeight: number;
  43415. /**
  43416. * Texture size (Default: 512)
  43417. */
  43418. textureSize: number;
  43419. /**
  43420. * If delta time between frames should be constant
  43421. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43422. */
  43423. deterministicLockstep: boolean;
  43424. /**
  43425. * Maximum about of steps between frames (Default: 4)
  43426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43427. */
  43428. lockstepMaxSteps: number;
  43429. }
  43430. /**
  43431. * The null engine class provides support for headless version of babylon.js.
  43432. * This can be used in server side scenario or for testing purposes
  43433. */
  43434. export class NullEngine extends Engine {
  43435. private _options;
  43436. /**
  43437. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43438. */
  43439. isDeterministicLockStep(): boolean;
  43440. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43441. getLockstepMaxSteps(): number;
  43442. /**
  43443. * Sets hardware scaling, used to save performance if needed
  43444. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43445. */
  43446. getHardwareScalingLevel(): number;
  43447. constructor(options?: NullEngineOptions);
  43448. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43449. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43450. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43451. getRenderWidth(useScreen?: boolean): number;
  43452. getRenderHeight(useScreen?: boolean): number;
  43453. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43454. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43455. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43456. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43457. bindSamplers(effect: Effect): void;
  43458. enableEffect(effect: Effect): void;
  43459. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43460. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43461. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43462. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43463. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43464. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43465. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43466. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43467. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43468. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43469. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43470. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43471. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43472. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43473. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43474. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43475. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43476. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43477. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43478. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43479. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43480. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43481. bindBuffers(vertexBuffers: {
  43482. [key: string]: VertexBuffer;
  43483. }, indexBuffer: DataBuffer, effect: Effect): void;
  43484. wipeCaches(bruteForce?: boolean): void;
  43485. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43486. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43487. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43488. /** @hidden */
  43489. _createTexture(): WebGLTexture;
  43490. /** @hidden */
  43491. _releaseTexture(texture: InternalTexture): void;
  43492. 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;
  43493. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43494. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43495. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43496. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43497. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43498. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43499. areAllEffectsReady(): boolean;
  43500. /**
  43501. * @hidden
  43502. * Get the current error code of the webGL context
  43503. * @returns the error code
  43504. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43505. */
  43506. getError(): number;
  43507. /** @hidden */
  43508. _getUnpackAlignement(): number;
  43509. /** @hidden */
  43510. _unpackFlipY(value: boolean): void;
  43511. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43512. /**
  43513. * Updates a dynamic vertex buffer.
  43514. * @param vertexBuffer the vertex buffer to update
  43515. * @param data the data used to update the vertex buffer
  43516. * @param byteOffset the byte offset of the data (optional)
  43517. * @param byteLength the byte length of the data (optional)
  43518. */
  43519. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43520. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43521. /** @hidden */
  43522. _bindTexture(channel: number, texture: InternalTexture): void;
  43523. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43524. releaseEffects(): void;
  43525. displayLoadingUI(): void;
  43526. hideLoadingUI(): void;
  43527. /** @hidden */
  43528. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43529. /** @hidden */
  43530. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43531. /** @hidden */
  43532. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43533. /** @hidden */
  43534. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43535. }
  43536. }
  43537. declare module BABYLON {
  43538. /** @hidden */
  43539. export class _OcclusionDataStorage {
  43540. /** @hidden */
  43541. occlusionInternalRetryCounter: number;
  43542. /** @hidden */
  43543. isOcclusionQueryInProgress: boolean;
  43544. /** @hidden */
  43545. isOccluded: boolean;
  43546. /** @hidden */
  43547. occlusionRetryCount: number;
  43548. /** @hidden */
  43549. occlusionType: number;
  43550. /** @hidden */
  43551. occlusionQueryAlgorithmType: number;
  43552. }
  43553. interface Engine {
  43554. /**
  43555. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43556. * @return the new query
  43557. */
  43558. createQuery(): WebGLQuery;
  43559. /**
  43560. * Delete and release a webGL query
  43561. * @param query defines the query to delete
  43562. * @return the current engine
  43563. */
  43564. deleteQuery(query: WebGLQuery): Engine;
  43565. /**
  43566. * Check if a given query has resolved and got its value
  43567. * @param query defines the query to check
  43568. * @returns true if the query got its value
  43569. */
  43570. isQueryResultAvailable(query: WebGLQuery): boolean;
  43571. /**
  43572. * Gets the value of a given query
  43573. * @param query defines the query to check
  43574. * @returns the value of the query
  43575. */
  43576. getQueryResult(query: WebGLQuery): number;
  43577. /**
  43578. * Initiates an occlusion query
  43579. * @param algorithmType defines the algorithm to use
  43580. * @param query defines the query to use
  43581. * @returns the current engine
  43582. * @see http://doc.babylonjs.com/features/occlusionquery
  43583. */
  43584. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43585. /**
  43586. * Ends an occlusion query
  43587. * @see http://doc.babylonjs.com/features/occlusionquery
  43588. * @param algorithmType defines the algorithm to use
  43589. * @returns the current engine
  43590. */
  43591. endOcclusionQuery(algorithmType: number): Engine;
  43592. /**
  43593. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43594. * Please note that only one query can be issued at a time
  43595. * @returns a time token used to track the time span
  43596. */
  43597. startTimeQuery(): Nullable<_TimeToken>;
  43598. /**
  43599. * Ends a time query
  43600. * @param token defines the token used to measure the time span
  43601. * @returns the time spent (in ns)
  43602. */
  43603. endTimeQuery(token: _TimeToken): int;
  43604. /** @hidden */
  43605. _currentNonTimestampToken: Nullable<_TimeToken>;
  43606. /** @hidden */
  43607. _createTimeQuery(): WebGLQuery;
  43608. /** @hidden */
  43609. _deleteTimeQuery(query: WebGLQuery): void;
  43610. /** @hidden */
  43611. _getGlAlgorithmType(algorithmType: number): number;
  43612. /** @hidden */
  43613. _getTimeQueryResult(query: WebGLQuery): any;
  43614. /** @hidden */
  43615. _getTimeQueryAvailability(query: WebGLQuery): any;
  43616. }
  43617. interface AbstractMesh {
  43618. /**
  43619. * Backing filed
  43620. * @hidden
  43621. */
  43622. __occlusionDataStorage: _OcclusionDataStorage;
  43623. /**
  43624. * Access property
  43625. * @hidden
  43626. */
  43627. _occlusionDataStorage: _OcclusionDataStorage;
  43628. /**
  43629. * 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.
  43630. * The default value is -1 which means don't break the query and wait till the result
  43631. * @see http://doc.babylonjs.com/features/occlusionquery
  43632. */
  43633. occlusionRetryCount: number;
  43634. /**
  43635. * 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:
  43636. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43637. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43638. * * 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.
  43639. * @see http://doc.babylonjs.com/features/occlusionquery
  43640. */
  43641. occlusionType: number;
  43642. /**
  43643. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43644. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43645. * * 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.
  43646. * @see http://doc.babylonjs.com/features/occlusionquery
  43647. */
  43648. occlusionQueryAlgorithmType: number;
  43649. /**
  43650. * 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
  43651. * @see http://doc.babylonjs.com/features/occlusionquery
  43652. */
  43653. isOccluded: boolean;
  43654. /**
  43655. * Flag to check the progress status of the query
  43656. * @see http://doc.babylonjs.com/features/occlusionquery
  43657. */
  43658. isOcclusionQueryInProgress: boolean;
  43659. }
  43660. }
  43661. declare module BABYLON {
  43662. /** @hidden */
  43663. export var _forceTransformFeedbackToBundle: boolean;
  43664. interface Engine {
  43665. /**
  43666. * Creates a webGL transform feedback object
  43667. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43668. * @returns the webGL transform feedback object
  43669. */
  43670. createTransformFeedback(): WebGLTransformFeedback;
  43671. /**
  43672. * Delete a webGL transform feedback object
  43673. * @param value defines the webGL transform feedback object to delete
  43674. */
  43675. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43676. /**
  43677. * Bind a webGL transform feedback object to the webgl context
  43678. * @param value defines the webGL transform feedback object to bind
  43679. */
  43680. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43681. /**
  43682. * Begins a transform feedback operation
  43683. * @param usePoints defines if points or triangles must be used
  43684. */
  43685. beginTransformFeedback(usePoints: boolean): void;
  43686. /**
  43687. * Ends a transform feedback operation
  43688. */
  43689. endTransformFeedback(): void;
  43690. /**
  43691. * Specify the varyings to use with transform feedback
  43692. * @param program defines the associated webGL program
  43693. * @param value defines the list of strings representing the varying names
  43694. */
  43695. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43696. /**
  43697. * Bind a webGL buffer for a transform feedback operation
  43698. * @param value defines the webGL buffer to bind
  43699. */
  43700. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43701. }
  43702. }
  43703. declare module BABYLON {
  43704. /**
  43705. * Creation options of the multi render target texture.
  43706. */
  43707. export interface IMultiRenderTargetOptions {
  43708. /**
  43709. * Define if the texture needs to create mip maps after render.
  43710. */
  43711. generateMipMaps?: boolean;
  43712. /**
  43713. * Define the types of all the draw buffers we want to create
  43714. */
  43715. types?: number[];
  43716. /**
  43717. * Define the sampling modes of all the draw buffers we want to create
  43718. */
  43719. samplingModes?: number[];
  43720. /**
  43721. * Define if a depth buffer is required
  43722. */
  43723. generateDepthBuffer?: boolean;
  43724. /**
  43725. * Define if a stencil buffer is required
  43726. */
  43727. generateStencilBuffer?: boolean;
  43728. /**
  43729. * Define if a depth texture is required instead of a depth buffer
  43730. */
  43731. generateDepthTexture?: boolean;
  43732. /**
  43733. * Define the number of desired draw buffers
  43734. */
  43735. textureCount?: number;
  43736. /**
  43737. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43738. */
  43739. doNotChangeAspectRatio?: boolean;
  43740. /**
  43741. * Define the default type of the buffers we are creating
  43742. */
  43743. defaultType?: number;
  43744. }
  43745. /**
  43746. * A multi render target, like a render target provides the ability to render to a texture.
  43747. * Unlike the render target, it can render to several draw buffers in one draw.
  43748. * This is specially interesting in deferred rendering or for any effects requiring more than
  43749. * just one color from a single pass.
  43750. */
  43751. export class MultiRenderTarget extends RenderTargetTexture {
  43752. private _internalTextures;
  43753. private _textures;
  43754. private _multiRenderTargetOptions;
  43755. /**
  43756. * Get if draw buffers are currently supported by the used hardware and browser.
  43757. */
  43758. readonly isSupported: boolean;
  43759. /**
  43760. * Get the list of textures generated by the multi render target.
  43761. */
  43762. readonly textures: Texture[];
  43763. /**
  43764. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43765. */
  43766. readonly depthTexture: Texture;
  43767. /**
  43768. * Set the wrapping mode on U of all the textures we are rendering to.
  43769. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43770. */
  43771. wrapU: number;
  43772. /**
  43773. * Set the wrapping mode on V of all the textures we are rendering to.
  43774. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43775. */
  43776. wrapV: number;
  43777. /**
  43778. * Instantiate a new multi render target texture.
  43779. * A multi render target, like a render target provides the ability to render to a texture.
  43780. * Unlike the render target, it can render to several draw buffers in one draw.
  43781. * This is specially interesting in deferred rendering or for any effects requiring more than
  43782. * just one color from a single pass.
  43783. * @param name Define the name of the texture
  43784. * @param size Define the size of the buffers to render to
  43785. * @param count Define the number of target we are rendering into
  43786. * @param scene Define the scene the texture belongs to
  43787. * @param options Define the options used to create the multi render target
  43788. */
  43789. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43790. /** @hidden */
  43791. _rebuild(): void;
  43792. private _createInternalTextures;
  43793. private _createTextures;
  43794. /**
  43795. * Define the number of samples used if MSAA is enabled.
  43796. */
  43797. samples: number;
  43798. /**
  43799. * Resize all the textures in the multi render target.
  43800. * Be carrefull as it will recreate all the data in the new texture.
  43801. * @param size Define the new size
  43802. */
  43803. resize(size: any): void;
  43804. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43805. /**
  43806. * Dispose the render targets and their associated resources
  43807. */
  43808. dispose(): void;
  43809. /**
  43810. * Release all the underlying texture used as draw buffers.
  43811. */
  43812. releaseInternalTextures(): void;
  43813. }
  43814. }
  43815. declare module BABYLON {
  43816. interface Engine {
  43817. /**
  43818. * Unbind a list of render target textures from the webGL context
  43819. * This is used only when drawBuffer extension or webGL2 are active
  43820. * @param textures defines the render target textures to unbind
  43821. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43822. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43823. */
  43824. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43825. /**
  43826. * Create a multi render target texture
  43827. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43828. * @param size defines the size of the texture
  43829. * @param options defines the creation options
  43830. * @returns the cube texture as an InternalTexture
  43831. */
  43832. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43833. /**
  43834. * Update the sample count for a given multiple render target texture
  43835. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43836. * @param textures defines the textures to update
  43837. * @param samples defines the sample count to set
  43838. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43839. */
  43840. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43841. }
  43842. }
  43843. declare module BABYLON {
  43844. /** @hidden */
  43845. export var rgbdEncodePixelShader: {
  43846. name: string;
  43847. shader: string;
  43848. };
  43849. }
  43850. declare module BABYLON {
  43851. /** @hidden */
  43852. export var rgbdDecodePixelShader: {
  43853. name: string;
  43854. shader: string;
  43855. };
  43856. }
  43857. declare module BABYLON {
  43858. /**
  43859. * Raw texture data and descriptor sufficient for WebGL texture upload
  43860. */
  43861. export interface EnvironmentTextureInfo {
  43862. /**
  43863. * Version of the environment map
  43864. */
  43865. version: number;
  43866. /**
  43867. * Width of image
  43868. */
  43869. width: number;
  43870. /**
  43871. * Irradiance information stored in the file.
  43872. */
  43873. irradiance: any;
  43874. /**
  43875. * Specular information stored in the file.
  43876. */
  43877. specular: any;
  43878. }
  43879. /**
  43880. * Defines One Image in the file. It requires only the position in the file
  43881. * as well as the length.
  43882. */
  43883. interface BufferImageData {
  43884. /**
  43885. * Length of the image data.
  43886. */
  43887. length: number;
  43888. /**
  43889. * Position of the data from the null terminator delimiting the end of the JSON.
  43890. */
  43891. position: number;
  43892. }
  43893. /**
  43894. * Defines the specular data enclosed in the file.
  43895. * This corresponds to the version 1 of the data.
  43896. */
  43897. export interface EnvironmentTextureSpecularInfoV1 {
  43898. /**
  43899. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43900. */
  43901. specularDataPosition?: number;
  43902. /**
  43903. * This contains all the images data needed to reconstruct the cubemap.
  43904. */
  43905. mipmaps: Array<BufferImageData>;
  43906. /**
  43907. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43908. */
  43909. lodGenerationScale: number;
  43910. }
  43911. /**
  43912. * Sets of helpers addressing the serialization and deserialization of environment texture
  43913. * stored in a BabylonJS env file.
  43914. * Those files are usually stored as .env files.
  43915. */
  43916. export class EnvironmentTextureTools {
  43917. /**
  43918. * Magic number identifying the env file.
  43919. */
  43920. private static _MagicBytes;
  43921. /**
  43922. * Gets the environment info from an env file.
  43923. * @param data The array buffer containing the .env bytes.
  43924. * @returns the environment file info (the json header) if successfully parsed.
  43925. */
  43926. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43927. /**
  43928. * Creates an environment texture from a loaded cube texture.
  43929. * @param texture defines the cube texture to convert in env file
  43930. * @return a promise containing the environment data if succesfull.
  43931. */
  43932. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43933. /**
  43934. * Creates a JSON representation of the spherical data.
  43935. * @param texture defines the texture containing the polynomials
  43936. * @return the JSON representation of the spherical info
  43937. */
  43938. private static _CreateEnvTextureIrradiance;
  43939. /**
  43940. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43941. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43942. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43943. * @return the views described by info providing access to the underlying buffer
  43944. */
  43945. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43946. /**
  43947. * Uploads the texture info contained in the env file to the GPU.
  43948. * @param texture defines the internal texture to upload to
  43949. * @param arrayBuffer defines the buffer cotaining the data to load
  43950. * @param info defines the texture info retrieved through the GetEnvInfo method
  43951. * @returns a promise
  43952. */
  43953. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43954. /**
  43955. * Uploads the levels of image data to the GPU.
  43956. * @param texture defines the internal texture to upload to
  43957. * @param imageData defines the array buffer views of image data [mipmap][face]
  43958. * @returns a promise
  43959. */
  43960. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43961. /**
  43962. * Uploads spherical polynomials information to the texture.
  43963. * @param texture defines the texture we are trying to upload the information to
  43964. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43965. */
  43966. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43967. /** @hidden */
  43968. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43969. }
  43970. }
  43971. declare module BABYLON {
  43972. /**
  43973. * Contains position and normal vectors for a vertex
  43974. */
  43975. export class PositionNormalVertex {
  43976. /** the position of the vertex (defaut: 0,0,0) */
  43977. position: Vector3;
  43978. /** the normal of the vertex (defaut: 0,1,0) */
  43979. normal: Vector3;
  43980. /**
  43981. * Creates a PositionNormalVertex
  43982. * @param position the position of the vertex (defaut: 0,0,0)
  43983. * @param normal the normal of the vertex (defaut: 0,1,0)
  43984. */
  43985. constructor(
  43986. /** the position of the vertex (defaut: 0,0,0) */
  43987. position?: Vector3,
  43988. /** the normal of the vertex (defaut: 0,1,0) */
  43989. normal?: Vector3);
  43990. /**
  43991. * Clones the PositionNormalVertex
  43992. * @returns the cloned PositionNormalVertex
  43993. */
  43994. clone(): PositionNormalVertex;
  43995. }
  43996. /**
  43997. * Contains position, normal and uv vectors for a vertex
  43998. */
  43999. export class PositionNormalTextureVertex {
  44000. /** the position of the vertex (defaut: 0,0,0) */
  44001. position: Vector3;
  44002. /** the normal of the vertex (defaut: 0,1,0) */
  44003. normal: Vector3;
  44004. /** the uv of the vertex (default: 0,0) */
  44005. uv: Vector2;
  44006. /**
  44007. * Creates a PositionNormalTextureVertex
  44008. * @param position the position of the vertex (defaut: 0,0,0)
  44009. * @param normal the normal of the vertex (defaut: 0,1,0)
  44010. * @param uv the uv of the vertex (default: 0,0)
  44011. */
  44012. constructor(
  44013. /** the position of the vertex (defaut: 0,0,0) */
  44014. position?: Vector3,
  44015. /** the normal of the vertex (defaut: 0,1,0) */
  44016. normal?: Vector3,
  44017. /** the uv of the vertex (default: 0,0) */
  44018. uv?: Vector2);
  44019. /**
  44020. * Clones the PositionNormalTextureVertex
  44021. * @returns the cloned PositionNormalTextureVertex
  44022. */
  44023. clone(): PositionNormalTextureVertex;
  44024. }
  44025. }
  44026. declare module BABYLON {
  44027. /** @hidden */
  44028. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44029. private _genericAttributeLocation;
  44030. private _varyingLocationCount;
  44031. private _varyingLocationMap;
  44032. private _replacements;
  44033. private _textureCount;
  44034. private _uniforms;
  44035. lineProcessor(line: string): string;
  44036. attributeProcessor(attribute: string): string;
  44037. varyingProcessor(varying: string, isFragment: boolean): string;
  44038. uniformProcessor(uniform: string): string;
  44039. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44040. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44041. }
  44042. }
  44043. declare module BABYLON {
  44044. /**
  44045. * Container for accessors for natively-stored mesh data buffers.
  44046. */
  44047. class NativeDataBuffer extends DataBuffer {
  44048. /**
  44049. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44050. */
  44051. nativeIndexBuffer?: any;
  44052. /**
  44053. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44054. */
  44055. nativeVertexBuffer?: any;
  44056. }
  44057. /** @hidden */
  44058. export class NativeEngine extends Engine {
  44059. private readonly _native;
  44060. getHardwareScalingLevel(): number;
  44061. constructor();
  44062. /**
  44063. * Can be used to override the current requestAnimationFrame requester.
  44064. * @hidden
  44065. */
  44066. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44067. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44068. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44069. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44070. recordVertexArrayObject(vertexBuffers: {
  44071. [key: string]: VertexBuffer;
  44072. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44073. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44074. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44075. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44076. /**
  44077. * Draw a list of indexed primitives
  44078. * @param fillMode defines the primitive to use
  44079. * @param indexStart defines the starting index
  44080. * @param indexCount defines the number of index to draw
  44081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44082. */
  44083. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44084. /**
  44085. * Draw a list of unindexed primitives
  44086. * @param fillMode defines the primitive to use
  44087. * @param verticesStart defines the index of first vertex to draw
  44088. * @param verticesCount defines the count of vertices to draw
  44089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44090. */
  44091. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44092. createPipelineContext(): IPipelineContext;
  44093. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44094. /** @hidden */
  44095. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44096. /** @hidden */
  44097. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44098. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44099. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44100. protected _setProgram(program: WebGLProgram): void;
  44101. _releaseEffect(effect: Effect): void;
  44102. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44103. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44104. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44105. bindSamplers(effect: Effect): void;
  44106. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44107. getRenderWidth(useScreen?: boolean): number;
  44108. getRenderHeight(useScreen?: boolean): number;
  44109. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44111. /**
  44112. * Set the z offset to apply to current rendering
  44113. * @param value defines the offset to apply
  44114. */
  44115. setZOffset(value: number): void;
  44116. /**
  44117. * Gets the current value of the zOffset
  44118. * @returns the current zOffset state
  44119. */
  44120. getZOffset(): number;
  44121. /**
  44122. * Enable or disable depth buffering
  44123. * @param enable defines the state to set
  44124. */
  44125. setDepthBuffer(enable: boolean): void;
  44126. /**
  44127. * Gets a boolean indicating if depth writing is enabled
  44128. * @returns the current depth writing state
  44129. */
  44130. getDepthWrite(): boolean;
  44131. /**
  44132. * Enable or disable depth writing
  44133. * @param enable defines the state to set
  44134. */
  44135. setDepthWrite(enable: boolean): void;
  44136. /**
  44137. * Enable or disable color writing
  44138. * @param enable defines the state to set
  44139. */
  44140. setColorWrite(enable: boolean): void;
  44141. /**
  44142. * Gets a boolean indicating if color writing is enabled
  44143. * @returns the current color writing state
  44144. */
  44145. getColorWrite(): boolean;
  44146. /**
  44147. * Sets alpha constants used by some alpha blending modes
  44148. * @param r defines the red component
  44149. * @param g defines the green component
  44150. * @param b defines the blue component
  44151. * @param a defines the alpha component
  44152. */
  44153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44154. /**
  44155. * Sets the current alpha mode
  44156. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44159. */
  44160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44161. /**
  44162. * Gets the current alpha mode
  44163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44164. * @returns the current alpha mode
  44165. */
  44166. getAlphaMode(): number;
  44167. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44168. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44169. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44170. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44171. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44172. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44173. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44174. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44175. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44176. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44177. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44178. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44179. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44180. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44181. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44182. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44183. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44184. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44185. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44186. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44187. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44188. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44189. wipeCaches(bruteForce?: boolean): void;
  44190. _createTexture(): WebGLTexture;
  44191. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44192. /**
  44193. * Usually called from BABYLON.Texture.ts.
  44194. * Passed information to create a WebGLTexture
  44195. * @param urlArg defines a value which contains one of the following:
  44196. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44197. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44198. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44199. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44200. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44201. * @param scene needed for loading to the correct scene
  44202. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44203. * @param onLoad optional callback to be called upon successful completion
  44204. * @param onError optional callback to be called upon failure
  44205. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44206. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44207. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44208. * @param forcedExtension defines the extension to use to pick the right loader
  44209. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44210. */
  44211. 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;
  44212. /**
  44213. * Creates a cube texture
  44214. * @param rootUrl defines the url where the files to load is located
  44215. * @param scene defines the current scene
  44216. * @param files defines the list of files to load (1 per face)
  44217. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44218. * @param onLoad defines an optional callback raised when the texture is loaded
  44219. * @param onError defines an optional callback raised if there is an issue to load the texture
  44220. * @param format defines the format of the data
  44221. * @param forcedExtension defines the extension to use to pick the right loader
  44222. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44223. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44224. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44225. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44226. * @returns the cube texture as an InternalTexture
  44227. */
  44228. 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;
  44229. private _getSamplingFilter;
  44230. private static _GetNativeTextureFormat;
  44231. createRenderTargetTexture(size: number | {
  44232. width: number;
  44233. height: number;
  44234. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44235. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44236. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44237. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44238. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44239. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44240. /**
  44241. * Updates a dynamic vertex buffer.
  44242. * @param vertexBuffer the vertex buffer to update
  44243. * @param data the data used to update the vertex buffer
  44244. * @param byteOffset the byte offset of the data (optional)
  44245. * @param byteLength the byte length of the data (optional)
  44246. */
  44247. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44248. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44249. private _updateAnisotropicLevel;
  44250. private _getAddressMode;
  44251. /** @hidden */
  44252. _bindTexture(channel: number, texture: InternalTexture): void;
  44253. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44254. releaseEffects(): void;
  44255. /** @hidden */
  44256. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44257. /** @hidden */
  44258. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44259. /** @hidden */
  44260. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44261. /** @hidden */
  44262. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44263. }
  44264. }
  44265. declare module BABYLON {
  44266. /**
  44267. * Gather the list of clipboard event types as constants.
  44268. */
  44269. export class ClipboardEventTypes {
  44270. /**
  44271. * The clipboard event is fired when a copy command is active (pressed).
  44272. */
  44273. static readonly COPY: number;
  44274. /**
  44275. * The clipboard event is fired when a cut command is active (pressed).
  44276. */
  44277. static readonly CUT: number;
  44278. /**
  44279. * The clipboard event is fired when a paste command is active (pressed).
  44280. */
  44281. static readonly PASTE: number;
  44282. }
  44283. /**
  44284. * This class is used to store clipboard related info for the onClipboardObservable event.
  44285. */
  44286. export class ClipboardInfo {
  44287. /**
  44288. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44289. */
  44290. type: number;
  44291. /**
  44292. * Defines the related dom event
  44293. */
  44294. event: ClipboardEvent;
  44295. /**
  44296. *Creates an instance of ClipboardInfo.
  44297. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44298. * @param event Defines the related dom event
  44299. */
  44300. constructor(
  44301. /**
  44302. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44303. */
  44304. type: number,
  44305. /**
  44306. * Defines the related dom event
  44307. */
  44308. event: ClipboardEvent);
  44309. /**
  44310. * Get the clipboard event's type from the keycode.
  44311. * @param keyCode Defines the keyCode for the current keyboard event.
  44312. * @return {number}
  44313. */
  44314. static GetTypeFromCharacter(keyCode: number): number;
  44315. }
  44316. }
  44317. declare module BABYLON {
  44318. /**
  44319. * Google Daydream controller
  44320. */
  44321. export class DaydreamController extends WebVRController {
  44322. /**
  44323. * Base Url for the controller model.
  44324. */
  44325. static MODEL_BASE_URL: string;
  44326. /**
  44327. * File name for the controller model.
  44328. */
  44329. static MODEL_FILENAME: string;
  44330. /**
  44331. * Gamepad Id prefix used to identify Daydream Controller.
  44332. */
  44333. static readonly GAMEPAD_ID_PREFIX: string;
  44334. /**
  44335. * Creates a new DaydreamController from a gamepad
  44336. * @param vrGamepad the gamepad that the controller should be created from
  44337. */
  44338. constructor(vrGamepad: any);
  44339. /**
  44340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44341. * @param scene scene in which to add meshes
  44342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44343. */
  44344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44345. /**
  44346. * Called once for each button that changed state since the last frame
  44347. * @param buttonIdx Which button index changed
  44348. * @param state New state of the button
  44349. * @param changes Which properties on the state changed since last frame
  44350. */
  44351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44352. }
  44353. }
  44354. declare module BABYLON {
  44355. /**
  44356. * Gear VR Controller
  44357. */
  44358. export class GearVRController extends WebVRController {
  44359. /**
  44360. * Base Url for the controller model.
  44361. */
  44362. static MODEL_BASE_URL: string;
  44363. /**
  44364. * File name for the controller model.
  44365. */
  44366. static MODEL_FILENAME: string;
  44367. /**
  44368. * Gamepad Id prefix used to identify this controller.
  44369. */
  44370. static readonly GAMEPAD_ID_PREFIX: string;
  44371. private readonly _buttonIndexToObservableNameMap;
  44372. /**
  44373. * Creates a new GearVRController from a gamepad
  44374. * @param vrGamepad the gamepad that the controller should be created from
  44375. */
  44376. constructor(vrGamepad: any);
  44377. /**
  44378. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44379. * @param scene scene in which to add meshes
  44380. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44381. */
  44382. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44383. /**
  44384. * Called once for each button that changed state since the last frame
  44385. * @param buttonIdx Which button index changed
  44386. * @param state New state of the button
  44387. * @param changes Which properties on the state changed since last frame
  44388. */
  44389. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44390. }
  44391. }
  44392. declare module BABYLON {
  44393. /**
  44394. * Class containing static functions to help procedurally build meshes
  44395. */
  44396. export class PolyhedronBuilder {
  44397. /**
  44398. * Creates a polyhedron mesh
  44399. * * 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
  44400. * * The parameter `size` (positive float, default 1) sets the polygon size
  44401. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44402. * * 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`
  44403. * * 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
  44404. * * 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)`)
  44405. * * 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
  44406. * * 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
  44407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44408. * * 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
  44409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44410. * @param name defines the name of the mesh
  44411. * @param options defines the options used to create the mesh
  44412. * @param scene defines the hosting scene
  44413. * @returns the polyhedron mesh
  44414. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44415. */
  44416. static CreatePolyhedron(name: string, options: {
  44417. type?: number;
  44418. size?: number;
  44419. sizeX?: number;
  44420. sizeY?: number;
  44421. sizeZ?: number;
  44422. custom?: any;
  44423. faceUV?: Vector4[];
  44424. faceColors?: Color4[];
  44425. flat?: boolean;
  44426. updatable?: boolean;
  44427. sideOrientation?: number;
  44428. frontUVs?: Vector4;
  44429. backUVs?: Vector4;
  44430. }, scene?: Nullable<Scene>): Mesh;
  44431. }
  44432. }
  44433. declare module BABYLON {
  44434. /**
  44435. * Gizmo that enables scaling a mesh along 3 axis
  44436. */
  44437. export class ScaleGizmo extends Gizmo {
  44438. /**
  44439. * Internal gizmo used for interactions on the x axis
  44440. */
  44441. xGizmo: AxisScaleGizmo;
  44442. /**
  44443. * Internal gizmo used for interactions on the y axis
  44444. */
  44445. yGizmo: AxisScaleGizmo;
  44446. /**
  44447. * Internal gizmo used for interactions on the z axis
  44448. */
  44449. zGizmo: AxisScaleGizmo;
  44450. /**
  44451. * Internal gizmo used to scale all axis equally
  44452. */
  44453. uniformScaleGizmo: AxisScaleGizmo;
  44454. private _meshAttached;
  44455. private _updateGizmoRotationToMatchAttachedMesh;
  44456. private _snapDistance;
  44457. private _scaleRatio;
  44458. private _uniformScalingMesh;
  44459. private _octahedron;
  44460. /** Fires an event when any of it's sub gizmos are dragged */
  44461. onDragStartObservable: Observable<unknown>;
  44462. /** Fires an event when any of it's sub gizmos are released from dragging */
  44463. onDragEndObservable: Observable<unknown>;
  44464. attachedMesh: Nullable<AbstractMesh>;
  44465. /**
  44466. * Creates a ScaleGizmo
  44467. * @param gizmoLayer The utility layer the gizmo will be added to
  44468. */
  44469. constructor(gizmoLayer?: UtilityLayerRenderer);
  44470. updateGizmoRotationToMatchAttachedMesh: boolean;
  44471. /**
  44472. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44473. */
  44474. snapDistance: number;
  44475. /**
  44476. * Ratio for the scale of the gizmo (Default: 1)
  44477. */
  44478. scaleRatio: number;
  44479. /**
  44480. * Disposes of the gizmo
  44481. */
  44482. dispose(): void;
  44483. }
  44484. }
  44485. declare module BABYLON {
  44486. /**
  44487. * Single axis scale gizmo
  44488. */
  44489. export class AxisScaleGizmo extends Gizmo {
  44490. /**
  44491. * Drag behavior responsible for the gizmos dragging interactions
  44492. */
  44493. dragBehavior: PointerDragBehavior;
  44494. private _pointerObserver;
  44495. /**
  44496. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44497. */
  44498. snapDistance: number;
  44499. /**
  44500. * Event that fires each time the gizmo snaps to a new location.
  44501. * * snapDistance is the the change in distance
  44502. */
  44503. onSnapObservable: Observable<{
  44504. snapDistance: number;
  44505. }>;
  44506. /**
  44507. * If the scaling operation should be done on all axis (default: false)
  44508. */
  44509. uniformScaling: boolean;
  44510. private _isEnabled;
  44511. private _parent;
  44512. private _arrow;
  44513. private _coloredMaterial;
  44514. private _hoverMaterial;
  44515. /**
  44516. * Creates an AxisScaleGizmo
  44517. * @param gizmoLayer The utility layer the gizmo will be added to
  44518. * @param dragAxis The axis which the gizmo will be able to scale on
  44519. * @param color The color of the gizmo
  44520. */
  44521. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44522. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44523. /**
  44524. * If the gizmo is enabled
  44525. */
  44526. isEnabled: boolean;
  44527. /**
  44528. * Disposes of the gizmo
  44529. */
  44530. dispose(): void;
  44531. /**
  44532. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44533. * @param mesh The mesh to replace the default mesh of the gizmo
  44534. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44535. */
  44536. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44537. }
  44538. }
  44539. declare module BABYLON {
  44540. /**
  44541. * Bounding box gizmo
  44542. */
  44543. export class BoundingBoxGizmo extends Gizmo {
  44544. private _lineBoundingBox;
  44545. private _rotateSpheresParent;
  44546. private _scaleBoxesParent;
  44547. private _boundingDimensions;
  44548. private _renderObserver;
  44549. private _pointerObserver;
  44550. private _scaleDragSpeed;
  44551. private _tmpQuaternion;
  44552. private _tmpVector;
  44553. private _tmpRotationMatrix;
  44554. /**
  44555. * 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)
  44556. */
  44557. ignoreChildren: boolean;
  44558. /**
  44559. * 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)
  44560. */
  44561. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44562. /**
  44563. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44564. */
  44565. rotationSphereSize: number;
  44566. /**
  44567. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44568. */
  44569. scaleBoxSize: number;
  44570. /**
  44571. * 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)
  44572. */
  44573. fixedDragMeshScreenSize: boolean;
  44574. /**
  44575. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44576. */
  44577. fixedDragMeshScreenSizeDistanceFactor: number;
  44578. /**
  44579. * Fired when a rotation sphere or scale box is dragged
  44580. */
  44581. onDragStartObservable: Observable<{}>;
  44582. /**
  44583. * Fired when a scale box is dragged
  44584. */
  44585. onScaleBoxDragObservable: Observable<{}>;
  44586. /**
  44587. * Fired when a scale box drag is ended
  44588. */
  44589. onScaleBoxDragEndObservable: Observable<{}>;
  44590. /**
  44591. * Fired when a rotation sphere is dragged
  44592. */
  44593. onRotationSphereDragObservable: Observable<{}>;
  44594. /**
  44595. * Fired when a rotation sphere drag is ended
  44596. */
  44597. onRotationSphereDragEndObservable: Observable<{}>;
  44598. /**
  44599. * 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)
  44600. */
  44601. scalePivot: Nullable<Vector3>;
  44602. /**
  44603. * Mesh used as a pivot to rotate the attached mesh
  44604. */
  44605. private _anchorMesh;
  44606. private _existingMeshScale;
  44607. private _dragMesh;
  44608. private pointerDragBehavior;
  44609. private coloredMaterial;
  44610. private hoverColoredMaterial;
  44611. /**
  44612. * Sets the color of the bounding box gizmo
  44613. * @param color the color to set
  44614. */
  44615. setColor(color: Color3): void;
  44616. /**
  44617. * Creates an BoundingBoxGizmo
  44618. * @param gizmoLayer The utility layer the gizmo will be added to
  44619. * @param color The color of the gizmo
  44620. */
  44621. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44623. private _selectNode;
  44624. /**
  44625. * Updates the bounding box information for the Gizmo
  44626. */
  44627. updateBoundingBox(): void;
  44628. private _updateRotationSpheres;
  44629. private _updateScaleBoxes;
  44630. /**
  44631. * Enables rotation on the specified axis and disables rotation on the others
  44632. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44633. */
  44634. setEnabledRotationAxis(axis: string): void;
  44635. /**
  44636. * Enables/disables scaling
  44637. * @param enable if scaling should be enabled
  44638. */
  44639. setEnabledScaling(enable: boolean): void;
  44640. private _updateDummy;
  44641. /**
  44642. * Enables a pointer drag behavior on the bounding box of the gizmo
  44643. */
  44644. enableDragBehavior(): void;
  44645. /**
  44646. * Disposes of the gizmo
  44647. */
  44648. dispose(): void;
  44649. /**
  44650. * 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)
  44651. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44652. * @returns the bounding box mesh with the passed in mesh as a child
  44653. */
  44654. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44655. /**
  44656. * CustomMeshes are not supported by this gizmo
  44657. * @param mesh The mesh to replace the default mesh of the gizmo
  44658. */
  44659. setCustomMesh(mesh: Mesh): void;
  44660. }
  44661. }
  44662. declare module BABYLON {
  44663. /**
  44664. * Single plane rotation gizmo
  44665. */
  44666. export class PlaneRotationGizmo extends Gizmo {
  44667. /**
  44668. * Drag behavior responsible for the gizmos dragging interactions
  44669. */
  44670. dragBehavior: PointerDragBehavior;
  44671. private _pointerObserver;
  44672. /**
  44673. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44674. */
  44675. snapDistance: number;
  44676. /**
  44677. * Event that fires each time the gizmo snaps to a new location.
  44678. * * snapDistance is the the change in distance
  44679. */
  44680. onSnapObservable: Observable<{
  44681. snapDistance: number;
  44682. }>;
  44683. private _isEnabled;
  44684. private _parent;
  44685. /**
  44686. * Creates a PlaneRotationGizmo
  44687. * @param gizmoLayer The utility layer the gizmo will be added to
  44688. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44689. * @param color The color of the gizmo
  44690. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44691. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44692. */
  44693. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44695. /**
  44696. * If the gizmo is enabled
  44697. */
  44698. isEnabled: boolean;
  44699. /**
  44700. * Disposes of the gizmo
  44701. */
  44702. dispose(): void;
  44703. }
  44704. }
  44705. declare module BABYLON {
  44706. /**
  44707. * Gizmo that enables rotating a mesh along 3 axis
  44708. */
  44709. export class RotationGizmo extends Gizmo {
  44710. /**
  44711. * Internal gizmo used for interactions on the x axis
  44712. */
  44713. xGizmo: PlaneRotationGizmo;
  44714. /**
  44715. * Internal gizmo used for interactions on the y axis
  44716. */
  44717. yGizmo: PlaneRotationGizmo;
  44718. /**
  44719. * Internal gizmo used for interactions on the z axis
  44720. */
  44721. zGizmo: PlaneRotationGizmo;
  44722. /** Fires an event when any of it's sub gizmos are dragged */
  44723. onDragStartObservable: Observable<unknown>;
  44724. /** Fires an event when any of it's sub gizmos are released from dragging */
  44725. onDragEndObservable: Observable<unknown>;
  44726. private _meshAttached;
  44727. attachedMesh: Nullable<AbstractMesh>;
  44728. /**
  44729. * Creates a RotationGizmo
  44730. * @param gizmoLayer The utility layer the gizmo will be added to
  44731. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44732. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44733. */
  44734. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44735. updateGizmoRotationToMatchAttachedMesh: boolean;
  44736. /**
  44737. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44738. */
  44739. snapDistance: number;
  44740. /**
  44741. * Ratio for the scale of the gizmo (Default: 1)
  44742. */
  44743. scaleRatio: number;
  44744. /**
  44745. * Disposes of the gizmo
  44746. */
  44747. dispose(): void;
  44748. /**
  44749. * CustomMeshes are not supported by this gizmo
  44750. * @param mesh The mesh to replace the default mesh of the gizmo
  44751. */
  44752. setCustomMesh(mesh: Mesh): void;
  44753. }
  44754. }
  44755. declare module BABYLON {
  44756. /**
  44757. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44758. */
  44759. export class GizmoManager implements IDisposable {
  44760. private scene;
  44761. /**
  44762. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44763. */
  44764. gizmos: {
  44765. positionGizmo: Nullable<PositionGizmo>;
  44766. rotationGizmo: Nullable<RotationGizmo>;
  44767. scaleGizmo: Nullable<ScaleGizmo>;
  44768. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44769. };
  44770. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44771. clearGizmoOnEmptyPointerEvent: boolean;
  44772. /** Fires an event when the manager is attached to a mesh */
  44773. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44774. private _gizmosEnabled;
  44775. private _pointerObserver;
  44776. private _attachedMesh;
  44777. private _boundingBoxColor;
  44778. private _defaultUtilityLayer;
  44779. private _defaultKeepDepthUtilityLayer;
  44780. /**
  44781. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44782. */
  44783. boundingBoxDragBehavior: SixDofDragBehavior;
  44784. /**
  44785. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44786. */
  44787. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44788. /**
  44789. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44790. */
  44791. usePointerToAttachGizmos: boolean;
  44792. /**
  44793. * Utility layer that the bounding box gizmo belongs to
  44794. */
  44795. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44796. /**
  44797. * Utility layer that all gizmos besides bounding box belong to
  44798. */
  44799. readonly utilityLayer: UtilityLayerRenderer;
  44800. /**
  44801. * Instatiates a gizmo manager
  44802. * @param scene the scene to overlay the gizmos on top of
  44803. */
  44804. constructor(scene: Scene);
  44805. /**
  44806. * Attaches a set of gizmos to the specified mesh
  44807. * @param mesh The mesh the gizmo's should be attached to
  44808. */
  44809. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44810. /**
  44811. * If the position gizmo is enabled
  44812. */
  44813. positionGizmoEnabled: boolean;
  44814. /**
  44815. * If the rotation gizmo is enabled
  44816. */
  44817. rotationGizmoEnabled: boolean;
  44818. /**
  44819. * If the scale gizmo is enabled
  44820. */
  44821. scaleGizmoEnabled: boolean;
  44822. /**
  44823. * If the boundingBox gizmo is enabled
  44824. */
  44825. boundingBoxGizmoEnabled: boolean;
  44826. /**
  44827. * Disposes of the gizmo manager
  44828. */
  44829. dispose(): void;
  44830. }
  44831. }
  44832. declare module BABYLON {
  44833. /**
  44834. * A directional light is defined by a direction (what a surprise!).
  44835. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44836. * 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.
  44837. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44838. */
  44839. export class DirectionalLight extends ShadowLight {
  44840. private _shadowFrustumSize;
  44841. /**
  44842. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44843. */
  44844. /**
  44845. * Specifies a fix frustum size for the shadow generation.
  44846. */
  44847. shadowFrustumSize: number;
  44848. private _shadowOrthoScale;
  44849. /**
  44850. * Gets the shadow projection scale against the optimal computed one.
  44851. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44852. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44853. */
  44854. /**
  44855. * Sets the shadow projection scale against the optimal computed one.
  44856. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44857. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44858. */
  44859. shadowOrthoScale: number;
  44860. /**
  44861. * Automatically compute the projection matrix to best fit (including all the casters)
  44862. * on each frame.
  44863. */
  44864. autoUpdateExtends: boolean;
  44865. private _orthoLeft;
  44866. private _orthoRight;
  44867. private _orthoTop;
  44868. private _orthoBottom;
  44869. /**
  44870. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44871. * The directional light is emitted from everywhere in the given direction.
  44872. * It can cast shadows.
  44873. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44874. * @param name The friendly name of the light
  44875. * @param direction The direction of the light
  44876. * @param scene The scene the light belongs to
  44877. */
  44878. constructor(name: string, direction: Vector3, scene: Scene);
  44879. /**
  44880. * Returns the string "DirectionalLight".
  44881. * @return The class name
  44882. */
  44883. getClassName(): string;
  44884. /**
  44885. * Returns the integer 1.
  44886. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44887. */
  44888. getTypeID(): number;
  44889. /**
  44890. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44891. * Returns the DirectionalLight Shadow projection matrix.
  44892. */
  44893. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44894. /**
  44895. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44896. * Returns the DirectionalLight Shadow projection matrix.
  44897. */
  44898. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44899. /**
  44900. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44901. * Returns the DirectionalLight Shadow projection matrix.
  44902. */
  44903. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44904. protected _buildUniformLayout(): void;
  44905. /**
  44906. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44907. * @param effect The effect to update
  44908. * @param lightIndex The index of the light in the effect to update
  44909. * @returns The directional light
  44910. */
  44911. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44912. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44913. /**
  44914. * Gets the minZ used for shadow according to both the scene and the light.
  44915. *
  44916. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44917. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44918. * @param activeCamera The camera we are returning the min for
  44919. * @returns the depth min z
  44920. */
  44921. getDepthMinZ(activeCamera: Camera): number;
  44922. /**
  44923. * Gets the maxZ used for shadow according to both the scene and the light.
  44924. *
  44925. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44926. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44927. * @param activeCamera The camera we are returning the max for
  44928. * @returns the depth max z
  44929. */
  44930. getDepthMaxZ(activeCamera: Camera): number;
  44931. /**
  44932. * Prepares the list of defines specific to the light type.
  44933. * @param defines the list of defines
  44934. * @param lightIndex defines the index of the light for the effect
  44935. */
  44936. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44937. }
  44938. }
  44939. declare module BABYLON {
  44940. /**
  44941. * Class containing static functions to help procedurally build meshes
  44942. */
  44943. export class HemisphereBuilder {
  44944. /**
  44945. * Creates a hemisphere mesh
  44946. * @param name defines the name of the mesh
  44947. * @param options defines the options used to create the mesh
  44948. * @param scene defines the hosting scene
  44949. * @returns the hemisphere mesh
  44950. */
  44951. static CreateHemisphere(name: string, options: {
  44952. segments?: number;
  44953. diameter?: number;
  44954. sideOrientation?: number;
  44955. }, scene: any): Mesh;
  44956. }
  44957. }
  44958. declare module BABYLON {
  44959. /**
  44960. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44961. * These values define a cone of light starting from the position, emitting toward the direction.
  44962. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44963. * and the exponent defines the speed of the decay of the light with distance (reach).
  44964. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44965. */
  44966. export class SpotLight extends ShadowLight {
  44967. private _angle;
  44968. private _innerAngle;
  44969. private _cosHalfAngle;
  44970. private _lightAngleScale;
  44971. private _lightAngleOffset;
  44972. /**
  44973. * Gets the cone angle of the spot light in Radians.
  44974. */
  44975. /**
  44976. * Sets the cone angle of the spot light in Radians.
  44977. */
  44978. angle: number;
  44979. /**
  44980. * Only used in gltf falloff mode, this defines the angle where
  44981. * the directional falloff will start before cutting at angle which could be seen
  44982. * as outer angle.
  44983. */
  44984. /**
  44985. * Only used in gltf falloff mode, this defines the angle where
  44986. * the directional falloff will start before cutting at angle which could be seen
  44987. * as outer angle.
  44988. */
  44989. innerAngle: number;
  44990. private _shadowAngleScale;
  44991. /**
  44992. * Allows scaling the angle of the light for shadow generation only.
  44993. */
  44994. /**
  44995. * Allows scaling the angle of the light for shadow generation only.
  44996. */
  44997. shadowAngleScale: number;
  44998. /**
  44999. * The light decay speed with the distance from the emission spot.
  45000. */
  45001. exponent: number;
  45002. private _projectionTextureMatrix;
  45003. /**
  45004. * Allows reading the projecton texture
  45005. */
  45006. readonly projectionTextureMatrix: Matrix;
  45007. protected _projectionTextureLightNear: number;
  45008. /**
  45009. * Gets the near clip of the Spotlight for texture projection.
  45010. */
  45011. /**
  45012. * Sets the near clip of the Spotlight for texture projection.
  45013. */
  45014. projectionTextureLightNear: number;
  45015. protected _projectionTextureLightFar: number;
  45016. /**
  45017. * Gets the far clip of the Spotlight for texture projection.
  45018. */
  45019. /**
  45020. * Sets the far clip of the Spotlight for texture projection.
  45021. */
  45022. projectionTextureLightFar: number;
  45023. protected _projectionTextureUpDirection: Vector3;
  45024. /**
  45025. * Gets the Up vector of the Spotlight for texture projection.
  45026. */
  45027. /**
  45028. * Sets the Up vector of the Spotlight for texture projection.
  45029. */
  45030. projectionTextureUpDirection: Vector3;
  45031. private _projectionTexture;
  45032. /**
  45033. * Gets the projection texture of the light.
  45034. */
  45035. /**
  45036. * Sets the projection texture of the light.
  45037. */
  45038. projectionTexture: Nullable<BaseTexture>;
  45039. private _projectionTextureViewLightDirty;
  45040. private _projectionTextureProjectionLightDirty;
  45041. private _projectionTextureDirty;
  45042. private _projectionTextureViewTargetVector;
  45043. private _projectionTextureViewLightMatrix;
  45044. private _projectionTextureProjectionLightMatrix;
  45045. private _projectionTextureScalingMatrix;
  45046. /**
  45047. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45048. * It can cast shadows.
  45049. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45050. * @param name The light friendly name
  45051. * @param position The position of the spot light in the scene
  45052. * @param direction The direction of the light in the scene
  45053. * @param angle The cone angle of the light in Radians
  45054. * @param exponent The light decay speed with the distance from the emission spot
  45055. * @param scene The scene the lights belongs to
  45056. */
  45057. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45058. /**
  45059. * Returns the string "SpotLight".
  45060. * @returns the class name
  45061. */
  45062. getClassName(): string;
  45063. /**
  45064. * Returns the integer 2.
  45065. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45066. */
  45067. getTypeID(): number;
  45068. /**
  45069. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45070. */
  45071. protected _setDirection(value: Vector3): void;
  45072. /**
  45073. * Overrides the position setter to recompute the projection texture view light Matrix.
  45074. */
  45075. protected _setPosition(value: Vector3): void;
  45076. /**
  45077. * 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.
  45078. * Returns the SpotLight.
  45079. */
  45080. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45081. protected _computeProjectionTextureViewLightMatrix(): void;
  45082. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45083. /**
  45084. * Main function for light texture projection matrix computing.
  45085. */
  45086. protected _computeProjectionTextureMatrix(): void;
  45087. protected _buildUniformLayout(): void;
  45088. private _computeAngleValues;
  45089. /**
  45090. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45091. * @param effect The effect to update
  45092. * @param lightIndex The index of the light in the effect to update
  45093. * @returns The spot light
  45094. */
  45095. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45096. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45097. /**
  45098. * Disposes the light and the associated resources.
  45099. */
  45100. dispose(): void;
  45101. /**
  45102. * Prepares the list of defines specific to the light type.
  45103. * @param defines the list of defines
  45104. * @param lightIndex defines the index of the light for the effect
  45105. */
  45106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45107. }
  45108. }
  45109. declare module BABYLON {
  45110. /**
  45111. * Gizmo that enables viewing a light
  45112. */
  45113. export class LightGizmo extends Gizmo {
  45114. private _lightMesh;
  45115. private _material;
  45116. private cachedPosition;
  45117. private cachedForward;
  45118. /**
  45119. * Creates a LightGizmo
  45120. * @param gizmoLayer The utility layer the gizmo will be added to
  45121. */
  45122. constructor(gizmoLayer?: UtilityLayerRenderer);
  45123. private _light;
  45124. /**
  45125. * The light that the gizmo is attached to
  45126. */
  45127. light: Nullable<Light>;
  45128. /**
  45129. * Gets the material used to render the light gizmo
  45130. */
  45131. readonly material: StandardMaterial;
  45132. /**
  45133. * @hidden
  45134. * Updates the gizmo to match the attached mesh's position/rotation
  45135. */
  45136. protected _update(): void;
  45137. private static _Scale;
  45138. /**
  45139. * Creates the lines for a light mesh
  45140. */
  45141. private static _createLightLines;
  45142. /**
  45143. * Disposes of the light gizmo
  45144. */
  45145. dispose(): void;
  45146. private static _CreateHemisphericLightMesh;
  45147. private static _CreatePointLightMesh;
  45148. private static _CreateSpotLightMesh;
  45149. private static _CreateDirectionalLightMesh;
  45150. }
  45151. }
  45152. declare module BABYLON {
  45153. /** @hidden */
  45154. export var backgroundFragmentDeclaration: {
  45155. name: string;
  45156. shader: string;
  45157. };
  45158. }
  45159. declare module BABYLON {
  45160. /** @hidden */
  45161. export var backgroundUboDeclaration: {
  45162. name: string;
  45163. shader: string;
  45164. };
  45165. }
  45166. declare module BABYLON {
  45167. /** @hidden */
  45168. export var backgroundPixelShader: {
  45169. name: string;
  45170. shader: string;
  45171. };
  45172. }
  45173. declare module BABYLON {
  45174. /** @hidden */
  45175. export var backgroundVertexDeclaration: {
  45176. name: string;
  45177. shader: string;
  45178. };
  45179. }
  45180. declare module BABYLON {
  45181. /** @hidden */
  45182. export var backgroundVertexShader: {
  45183. name: string;
  45184. shader: string;
  45185. };
  45186. }
  45187. declare module BABYLON {
  45188. /**
  45189. * Background material used to create an efficient environement around your scene.
  45190. */
  45191. export class BackgroundMaterial extends PushMaterial {
  45192. /**
  45193. * Standard reflectance value at parallel view angle.
  45194. */
  45195. static StandardReflectance0: number;
  45196. /**
  45197. * Standard reflectance value at grazing angle.
  45198. */
  45199. static StandardReflectance90: number;
  45200. protected _primaryColor: Color3;
  45201. /**
  45202. * Key light Color (multiply against the environement texture)
  45203. */
  45204. primaryColor: Color3;
  45205. protected __perceptualColor: Nullable<Color3>;
  45206. /**
  45207. * Experimental Internal Use Only.
  45208. *
  45209. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45210. * This acts as a helper to set the primary color to a more "human friendly" value.
  45211. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45212. * output color as close as possible from the chosen value.
  45213. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45214. * part of lighting setup.)
  45215. */
  45216. _perceptualColor: Nullable<Color3>;
  45217. protected _primaryColorShadowLevel: float;
  45218. /**
  45219. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45220. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45221. */
  45222. primaryColorShadowLevel: float;
  45223. protected _primaryColorHighlightLevel: float;
  45224. /**
  45225. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45226. * The primary color is used at the level chosen to define what the white area would look.
  45227. */
  45228. primaryColorHighlightLevel: float;
  45229. protected _reflectionTexture: Nullable<BaseTexture>;
  45230. /**
  45231. * Reflection Texture used in the material.
  45232. * Should be author in a specific way for the best result (refer to the documentation).
  45233. */
  45234. reflectionTexture: Nullable<BaseTexture>;
  45235. protected _reflectionBlur: float;
  45236. /**
  45237. * Reflection Texture level of blur.
  45238. *
  45239. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45240. * texture twice.
  45241. */
  45242. reflectionBlur: float;
  45243. protected _diffuseTexture: Nullable<BaseTexture>;
  45244. /**
  45245. * Diffuse Texture used in the material.
  45246. * Should be author in a specific way for the best result (refer to the documentation).
  45247. */
  45248. diffuseTexture: Nullable<BaseTexture>;
  45249. protected _shadowLights: Nullable<IShadowLight[]>;
  45250. /**
  45251. * Specify the list of lights casting shadow on the material.
  45252. * All scene shadow lights will be included if null.
  45253. */
  45254. shadowLights: Nullable<IShadowLight[]>;
  45255. protected _shadowLevel: float;
  45256. /**
  45257. * Helps adjusting the shadow to a softer level if required.
  45258. * 0 means black shadows and 1 means no shadows.
  45259. */
  45260. shadowLevel: float;
  45261. protected _sceneCenter: Vector3;
  45262. /**
  45263. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45264. * It is usually zero but might be interesting to modify according to your setup.
  45265. */
  45266. sceneCenter: Vector3;
  45267. protected _opacityFresnel: boolean;
  45268. /**
  45269. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45270. * This helps ensuring a nice transition when the camera goes under the ground.
  45271. */
  45272. opacityFresnel: boolean;
  45273. protected _reflectionFresnel: boolean;
  45274. /**
  45275. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45276. * This helps adding a mirror texture on the ground.
  45277. */
  45278. reflectionFresnel: boolean;
  45279. protected _reflectionFalloffDistance: number;
  45280. /**
  45281. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45282. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45283. */
  45284. reflectionFalloffDistance: number;
  45285. protected _reflectionAmount: number;
  45286. /**
  45287. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45288. */
  45289. reflectionAmount: number;
  45290. protected _reflectionReflectance0: number;
  45291. /**
  45292. * This specifies the weight of the reflection at grazing angle.
  45293. */
  45294. reflectionReflectance0: number;
  45295. protected _reflectionReflectance90: number;
  45296. /**
  45297. * This specifies the weight of the reflection at a perpendicular point of view.
  45298. */
  45299. reflectionReflectance90: number;
  45300. /**
  45301. * Sets the reflection reflectance fresnel values according to the default standard
  45302. * empirically know to work well :-)
  45303. */
  45304. reflectionStandardFresnelWeight: number;
  45305. protected _useRGBColor: boolean;
  45306. /**
  45307. * Helps to directly use the maps channels instead of their level.
  45308. */
  45309. useRGBColor: boolean;
  45310. protected _enableNoise: boolean;
  45311. /**
  45312. * This helps reducing the banding effect that could occur on the background.
  45313. */
  45314. enableNoise: boolean;
  45315. /**
  45316. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45317. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45318. * Recommended to be keep at 1.0 except for special cases.
  45319. */
  45320. fovMultiplier: number;
  45321. private _fovMultiplier;
  45322. /**
  45323. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45324. */
  45325. useEquirectangularFOV: boolean;
  45326. private _maxSimultaneousLights;
  45327. /**
  45328. * Number of Simultaneous lights allowed on the material.
  45329. */
  45330. maxSimultaneousLights: int;
  45331. /**
  45332. * Default configuration related to image processing available in the Background Material.
  45333. */
  45334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45335. /**
  45336. * Keep track of the image processing observer to allow dispose and replace.
  45337. */
  45338. private _imageProcessingObserver;
  45339. /**
  45340. * Attaches a new image processing configuration to the PBR Material.
  45341. * @param configuration (if null the scene configuration will be use)
  45342. */
  45343. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45344. /**
  45345. * Gets the image processing configuration used either in this material.
  45346. */
  45347. /**
  45348. * Sets the Default image processing configuration used either in the this material.
  45349. *
  45350. * If sets to null, the scene one is in use.
  45351. */
  45352. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45353. /**
  45354. * Gets wether the color curves effect is enabled.
  45355. */
  45356. /**
  45357. * Sets wether the color curves effect is enabled.
  45358. */
  45359. cameraColorCurvesEnabled: boolean;
  45360. /**
  45361. * Gets wether the color grading effect is enabled.
  45362. */
  45363. /**
  45364. * Gets wether the color grading effect is enabled.
  45365. */
  45366. cameraColorGradingEnabled: boolean;
  45367. /**
  45368. * Gets wether tonemapping is enabled or not.
  45369. */
  45370. /**
  45371. * Sets wether tonemapping is enabled or not
  45372. */
  45373. cameraToneMappingEnabled: boolean;
  45374. /**
  45375. * The camera exposure used on this material.
  45376. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45377. * This corresponds to a photographic exposure.
  45378. */
  45379. /**
  45380. * The camera exposure used on this material.
  45381. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45382. * This corresponds to a photographic exposure.
  45383. */
  45384. cameraExposure: float;
  45385. /**
  45386. * Gets The camera contrast used on this material.
  45387. */
  45388. /**
  45389. * Sets The camera contrast used on this material.
  45390. */
  45391. cameraContrast: float;
  45392. /**
  45393. * Gets the Color Grading 2D Lookup Texture.
  45394. */
  45395. /**
  45396. * Sets the Color Grading 2D Lookup Texture.
  45397. */
  45398. cameraColorGradingTexture: Nullable<BaseTexture>;
  45399. /**
  45400. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45401. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45402. * 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;
  45403. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45404. */
  45405. /**
  45406. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45407. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45408. * 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;
  45409. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45410. */
  45411. cameraColorCurves: Nullable<ColorCurves>;
  45412. /**
  45413. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45414. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45415. */
  45416. switchToBGR: boolean;
  45417. private _renderTargets;
  45418. private _reflectionControls;
  45419. private _white;
  45420. private _primaryShadowColor;
  45421. private _primaryHighlightColor;
  45422. /**
  45423. * Instantiates a Background Material in the given scene
  45424. * @param name The friendly name of the material
  45425. * @param scene The scene to add the material to
  45426. */
  45427. constructor(name: string, scene: Scene);
  45428. /**
  45429. * Gets a boolean indicating that current material needs to register RTT
  45430. */
  45431. readonly hasRenderTargetTextures: boolean;
  45432. /**
  45433. * The entire material has been created in order to prevent overdraw.
  45434. * @returns false
  45435. */
  45436. needAlphaTesting(): boolean;
  45437. /**
  45438. * The entire material has been created in order to prevent overdraw.
  45439. * @returns true if blending is enable
  45440. */
  45441. needAlphaBlending(): boolean;
  45442. /**
  45443. * Checks wether the material is ready to be rendered for a given mesh.
  45444. * @param mesh The mesh to render
  45445. * @param subMesh The submesh to check against
  45446. * @param useInstances Specify wether or not the material is used with instances
  45447. * @returns true if all the dependencies are ready (Textures, Effects...)
  45448. */
  45449. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45450. /**
  45451. * Compute the primary color according to the chosen perceptual color.
  45452. */
  45453. private _computePrimaryColorFromPerceptualColor;
  45454. /**
  45455. * Compute the highlights and shadow colors according to their chosen levels.
  45456. */
  45457. private _computePrimaryColors;
  45458. /**
  45459. * Build the uniform buffer used in the material.
  45460. */
  45461. buildUniformLayout(): void;
  45462. /**
  45463. * Unbind the material.
  45464. */
  45465. unbind(): void;
  45466. /**
  45467. * Bind only the world matrix to the material.
  45468. * @param world The world matrix to bind.
  45469. */
  45470. bindOnlyWorldMatrix(world: Matrix): void;
  45471. /**
  45472. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45473. * @param world The world matrix to bind.
  45474. * @param subMesh The submesh to bind for.
  45475. */
  45476. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45477. /**
  45478. * Checks to see if a texture is used in the material.
  45479. * @param texture - Base texture to use.
  45480. * @returns - Boolean specifying if a texture is used in the material.
  45481. */
  45482. hasTexture(texture: BaseTexture): boolean;
  45483. /**
  45484. * Dispose the material.
  45485. * @param forceDisposeEffect Force disposal of the associated effect.
  45486. * @param forceDisposeTextures Force disposal of the associated textures.
  45487. */
  45488. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45489. /**
  45490. * Clones the material.
  45491. * @param name The cloned name.
  45492. * @returns The cloned material.
  45493. */
  45494. clone(name: string): BackgroundMaterial;
  45495. /**
  45496. * Serializes the current material to its JSON representation.
  45497. * @returns The JSON representation.
  45498. */
  45499. serialize(): any;
  45500. /**
  45501. * Gets the class name of the material
  45502. * @returns "BackgroundMaterial"
  45503. */
  45504. getClassName(): string;
  45505. /**
  45506. * Parse a JSON input to create back a background material.
  45507. * @param source The JSON data to parse
  45508. * @param scene The scene to create the parsed material in
  45509. * @param rootUrl The root url of the assets the material depends upon
  45510. * @returns the instantiated BackgroundMaterial.
  45511. */
  45512. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45513. }
  45514. }
  45515. declare module BABYLON {
  45516. /**
  45517. * Represents the different options available during the creation of
  45518. * a Environment helper.
  45519. *
  45520. * This can control the default ground, skybox and image processing setup of your scene.
  45521. */
  45522. export interface IEnvironmentHelperOptions {
  45523. /**
  45524. * Specifies wether or not to create a ground.
  45525. * True by default.
  45526. */
  45527. createGround: boolean;
  45528. /**
  45529. * Specifies the ground size.
  45530. * 15 by default.
  45531. */
  45532. groundSize: number;
  45533. /**
  45534. * The texture used on the ground for the main color.
  45535. * Comes from the BabylonJS CDN by default.
  45536. *
  45537. * Remarks: Can be either a texture or a url.
  45538. */
  45539. groundTexture: string | BaseTexture;
  45540. /**
  45541. * The color mixed in the ground texture by default.
  45542. * BabylonJS clearColor by default.
  45543. */
  45544. groundColor: Color3;
  45545. /**
  45546. * Specifies the ground opacity.
  45547. * 1 by default.
  45548. */
  45549. groundOpacity: number;
  45550. /**
  45551. * Enables the ground to receive shadows.
  45552. * True by default.
  45553. */
  45554. enableGroundShadow: boolean;
  45555. /**
  45556. * Helps preventing the shadow to be fully black on the ground.
  45557. * 0.5 by default.
  45558. */
  45559. groundShadowLevel: number;
  45560. /**
  45561. * Creates a mirror texture attach to the ground.
  45562. * false by default.
  45563. */
  45564. enableGroundMirror: boolean;
  45565. /**
  45566. * Specifies the ground mirror size ratio.
  45567. * 0.3 by default as the default kernel is 64.
  45568. */
  45569. groundMirrorSizeRatio: number;
  45570. /**
  45571. * Specifies the ground mirror blur kernel size.
  45572. * 64 by default.
  45573. */
  45574. groundMirrorBlurKernel: number;
  45575. /**
  45576. * Specifies the ground mirror visibility amount.
  45577. * 1 by default
  45578. */
  45579. groundMirrorAmount: number;
  45580. /**
  45581. * Specifies the ground mirror reflectance weight.
  45582. * This uses the standard weight of the background material to setup the fresnel effect
  45583. * of the mirror.
  45584. * 1 by default.
  45585. */
  45586. groundMirrorFresnelWeight: number;
  45587. /**
  45588. * Specifies the ground mirror Falloff distance.
  45589. * This can helps reducing the size of the reflection.
  45590. * 0 by Default.
  45591. */
  45592. groundMirrorFallOffDistance: number;
  45593. /**
  45594. * Specifies the ground mirror texture type.
  45595. * Unsigned Int by Default.
  45596. */
  45597. groundMirrorTextureType: number;
  45598. /**
  45599. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45600. * the shown objects.
  45601. */
  45602. groundYBias: number;
  45603. /**
  45604. * Specifies wether or not to create a skybox.
  45605. * True by default.
  45606. */
  45607. createSkybox: boolean;
  45608. /**
  45609. * Specifies the skybox size.
  45610. * 20 by default.
  45611. */
  45612. skyboxSize: number;
  45613. /**
  45614. * The texture used on the skybox for the main color.
  45615. * Comes from the BabylonJS CDN by default.
  45616. *
  45617. * Remarks: Can be either a texture or a url.
  45618. */
  45619. skyboxTexture: string | BaseTexture;
  45620. /**
  45621. * The color mixed in the skybox texture by default.
  45622. * BabylonJS clearColor by default.
  45623. */
  45624. skyboxColor: Color3;
  45625. /**
  45626. * The background rotation around the Y axis of the scene.
  45627. * This helps aligning the key lights of your scene with the background.
  45628. * 0 by default.
  45629. */
  45630. backgroundYRotation: number;
  45631. /**
  45632. * Compute automatically the size of the elements to best fit with the scene.
  45633. */
  45634. sizeAuto: boolean;
  45635. /**
  45636. * Default position of the rootMesh if autoSize is not true.
  45637. */
  45638. rootPosition: Vector3;
  45639. /**
  45640. * Sets up the image processing in the scene.
  45641. * true by default.
  45642. */
  45643. setupImageProcessing: boolean;
  45644. /**
  45645. * The texture used as your environment texture in the scene.
  45646. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45647. *
  45648. * Remarks: Can be either a texture or a url.
  45649. */
  45650. environmentTexture: string | BaseTexture;
  45651. /**
  45652. * The value of the exposure to apply to the scene.
  45653. * 0.6 by default if setupImageProcessing is true.
  45654. */
  45655. cameraExposure: number;
  45656. /**
  45657. * The value of the contrast to apply to the scene.
  45658. * 1.6 by default if setupImageProcessing is true.
  45659. */
  45660. cameraContrast: number;
  45661. /**
  45662. * Specifies wether or not tonemapping should be enabled in the scene.
  45663. * true by default if setupImageProcessing is true.
  45664. */
  45665. toneMappingEnabled: boolean;
  45666. }
  45667. /**
  45668. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45669. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45670. * It also helps with the default setup of your imageProcessing configuration.
  45671. */
  45672. export class EnvironmentHelper {
  45673. /**
  45674. * Default ground texture URL.
  45675. */
  45676. private static _groundTextureCDNUrl;
  45677. /**
  45678. * Default skybox texture URL.
  45679. */
  45680. private static _skyboxTextureCDNUrl;
  45681. /**
  45682. * Default environment texture URL.
  45683. */
  45684. private static _environmentTextureCDNUrl;
  45685. /**
  45686. * Creates the default options for the helper.
  45687. */
  45688. private static _getDefaultOptions;
  45689. private _rootMesh;
  45690. /**
  45691. * Gets the root mesh created by the helper.
  45692. */
  45693. readonly rootMesh: Mesh;
  45694. private _skybox;
  45695. /**
  45696. * Gets the skybox created by the helper.
  45697. */
  45698. readonly skybox: Nullable<Mesh>;
  45699. private _skyboxTexture;
  45700. /**
  45701. * Gets the skybox texture created by the helper.
  45702. */
  45703. readonly skyboxTexture: Nullable<BaseTexture>;
  45704. private _skyboxMaterial;
  45705. /**
  45706. * Gets the skybox material created by the helper.
  45707. */
  45708. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45709. private _ground;
  45710. /**
  45711. * Gets the ground mesh created by the helper.
  45712. */
  45713. readonly ground: Nullable<Mesh>;
  45714. private _groundTexture;
  45715. /**
  45716. * Gets the ground texture created by the helper.
  45717. */
  45718. readonly groundTexture: Nullable<BaseTexture>;
  45719. private _groundMirror;
  45720. /**
  45721. * Gets the ground mirror created by the helper.
  45722. */
  45723. readonly groundMirror: Nullable<MirrorTexture>;
  45724. /**
  45725. * Gets the ground mirror render list to helps pushing the meshes
  45726. * you wish in the ground reflection.
  45727. */
  45728. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45729. private _groundMaterial;
  45730. /**
  45731. * Gets the ground material created by the helper.
  45732. */
  45733. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45734. /**
  45735. * Stores the creation options.
  45736. */
  45737. private readonly _scene;
  45738. private _options;
  45739. /**
  45740. * This observable will be notified with any error during the creation of the environment,
  45741. * mainly texture creation errors.
  45742. */
  45743. onErrorObservable: Observable<{
  45744. message?: string;
  45745. exception?: any;
  45746. }>;
  45747. /**
  45748. * constructor
  45749. * @param options Defines the options we want to customize the helper
  45750. * @param scene The scene to add the material to
  45751. */
  45752. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45753. /**
  45754. * Updates the background according to the new options
  45755. * @param options
  45756. */
  45757. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45758. /**
  45759. * Sets the primary color of all the available elements.
  45760. * @param color the main color to affect to the ground and the background
  45761. */
  45762. setMainColor(color: Color3): void;
  45763. /**
  45764. * Setup the image processing according to the specified options.
  45765. */
  45766. private _setupImageProcessing;
  45767. /**
  45768. * Setup the environment texture according to the specified options.
  45769. */
  45770. private _setupEnvironmentTexture;
  45771. /**
  45772. * Setup the background according to the specified options.
  45773. */
  45774. private _setupBackground;
  45775. /**
  45776. * Get the scene sizes according to the setup.
  45777. */
  45778. private _getSceneSize;
  45779. /**
  45780. * Setup the ground according to the specified options.
  45781. */
  45782. private _setupGround;
  45783. /**
  45784. * Setup the ground material according to the specified options.
  45785. */
  45786. private _setupGroundMaterial;
  45787. /**
  45788. * Setup the ground diffuse texture according to the specified options.
  45789. */
  45790. private _setupGroundDiffuseTexture;
  45791. /**
  45792. * Setup the ground mirror texture according to the specified options.
  45793. */
  45794. private _setupGroundMirrorTexture;
  45795. /**
  45796. * Setup the ground to receive the mirror texture.
  45797. */
  45798. private _setupMirrorInGroundMaterial;
  45799. /**
  45800. * Setup the skybox according to the specified options.
  45801. */
  45802. private _setupSkybox;
  45803. /**
  45804. * Setup the skybox material according to the specified options.
  45805. */
  45806. private _setupSkyboxMaterial;
  45807. /**
  45808. * Setup the skybox reflection texture according to the specified options.
  45809. */
  45810. private _setupSkyboxReflectionTexture;
  45811. private _errorHandler;
  45812. /**
  45813. * Dispose all the elements created by the Helper.
  45814. */
  45815. dispose(): void;
  45816. }
  45817. }
  45818. declare module BABYLON {
  45819. /**
  45820. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45821. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45822. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45823. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45824. */
  45825. export class PhotoDome extends TransformNode {
  45826. /**
  45827. * Define the image as a Monoscopic panoramic 360 image.
  45828. */
  45829. static readonly MODE_MONOSCOPIC: number;
  45830. /**
  45831. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45832. */
  45833. static readonly MODE_TOPBOTTOM: number;
  45834. /**
  45835. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45836. */
  45837. static readonly MODE_SIDEBYSIDE: number;
  45838. private _useDirectMapping;
  45839. /**
  45840. * The texture being displayed on the sphere
  45841. */
  45842. protected _photoTexture: Texture;
  45843. /**
  45844. * Gets or sets the texture being displayed on the sphere
  45845. */
  45846. photoTexture: Texture;
  45847. /**
  45848. * Observable raised when an error occured while loading the 360 image
  45849. */
  45850. onLoadErrorObservable: Observable<string>;
  45851. /**
  45852. * The skybox material
  45853. */
  45854. protected _material: BackgroundMaterial;
  45855. /**
  45856. * The surface used for the skybox
  45857. */
  45858. protected _mesh: Mesh;
  45859. /**
  45860. * Gets the mesh used for the skybox.
  45861. */
  45862. readonly mesh: Mesh;
  45863. /**
  45864. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45865. * Also see the options.resolution property.
  45866. */
  45867. fovMultiplier: number;
  45868. private _imageMode;
  45869. /**
  45870. * Gets or set the current video mode for the video. It can be:
  45871. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45872. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45873. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45874. */
  45875. imageMode: number;
  45876. /**
  45877. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45878. * @param name Element's name, child elements will append suffixes for their own names.
  45879. * @param urlsOfPhoto defines the url of the photo to display
  45880. * @param options defines an object containing optional or exposed sub element properties
  45881. * @param onError defines a callback called when an error occured while loading the texture
  45882. */
  45883. constructor(name: string, urlOfPhoto: string, options: {
  45884. resolution?: number;
  45885. size?: number;
  45886. useDirectMapping?: boolean;
  45887. faceForward?: boolean;
  45888. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45889. private _onBeforeCameraRenderObserver;
  45890. private _changeImageMode;
  45891. /**
  45892. * Releases resources associated with this node.
  45893. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45894. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45895. */
  45896. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45897. }
  45898. }
  45899. declare module BABYLON {
  45900. /**
  45901. * Class used to host RGBD texture specific utilities
  45902. */
  45903. export class RGBDTextureTools {
  45904. /**
  45905. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45906. * @param texture the texture to expand.
  45907. */
  45908. static ExpandRGBDTexture(texture: Texture): void;
  45909. }
  45910. }
  45911. declare module BABYLON {
  45912. /**
  45913. * Class used to host texture specific utilities
  45914. */
  45915. export class BRDFTextureTools {
  45916. /**
  45917. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45918. * @param scene defines the hosting scene
  45919. * @returns the environment BRDF texture
  45920. */
  45921. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45922. private static _environmentBRDFBase64Texture;
  45923. }
  45924. }
  45925. declare module BABYLON {
  45926. /**
  45927. * @hidden
  45928. */
  45929. export interface IMaterialClearCoatDefines {
  45930. CLEARCOAT: boolean;
  45931. CLEARCOAT_DEFAULTIOR: boolean;
  45932. CLEARCOAT_TEXTURE: boolean;
  45933. CLEARCOAT_TEXTUREDIRECTUV: number;
  45934. CLEARCOAT_BUMP: boolean;
  45935. CLEARCOAT_BUMPDIRECTUV: number;
  45936. CLEARCOAT_TINT: boolean;
  45937. CLEARCOAT_TINT_TEXTURE: boolean;
  45938. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45939. /** @hidden */
  45940. _areTexturesDirty: boolean;
  45941. }
  45942. /**
  45943. * Define the code related to the clear coat parameters of the pbr material.
  45944. */
  45945. export class PBRClearCoatConfiguration {
  45946. /**
  45947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45948. * The default fits with a polyurethane material.
  45949. */
  45950. private static readonly _DefaultIndexOfRefraction;
  45951. private _isEnabled;
  45952. /**
  45953. * Defines if the clear coat is enabled in the material.
  45954. */
  45955. isEnabled: boolean;
  45956. /**
  45957. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45958. */
  45959. intensity: number;
  45960. /**
  45961. * Defines the clear coat layer roughness.
  45962. */
  45963. roughness: number;
  45964. private _indexOfRefraction;
  45965. /**
  45966. * Defines the index of refraction of the clear coat.
  45967. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45968. * The default fits with a polyurethane material.
  45969. * Changing the default value is more performance intensive.
  45970. */
  45971. indexOfRefraction: number;
  45972. private _texture;
  45973. /**
  45974. * Stores the clear coat values in a texture.
  45975. */
  45976. texture: Nullable<BaseTexture>;
  45977. private _bumpTexture;
  45978. /**
  45979. * Define the clear coat specific bump texture.
  45980. */
  45981. bumpTexture: Nullable<BaseTexture>;
  45982. private _isTintEnabled;
  45983. /**
  45984. * Defines if the clear coat tint is enabled in the material.
  45985. */
  45986. isTintEnabled: boolean;
  45987. /**
  45988. * Defines the clear coat tint of the material.
  45989. * This is only use if tint is enabled
  45990. */
  45991. tintColor: Color3;
  45992. /**
  45993. * Defines the distance at which the tint color should be found in the
  45994. * clear coat media.
  45995. * This is only use if tint is enabled
  45996. */
  45997. tintColorAtDistance: number;
  45998. /**
  45999. * Defines the clear coat layer thickness.
  46000. * This is only use if tint is enabled
  46001. */
  46002. tintThickness: number;
  46003. private _tintTexture;
  46004. /**
  46005. * Stores the clear tint values in a texture.
  46006. * rgb is tint
  46007. * a is a thickness factor
  46008. */
  46009. tintTexture: Nullable<BaseTexture>;
  46010. /** @hidden */
  46011. private _internalMarkAllSubMeshesAsTexturesDirty;
  46012. /** @hidden */
  46013. _markAllSubMeshesAsTexturesDirty(): void;
  46014. /**
  46015. * Instantiate a new istance of clear coat configuration.
  46016. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46017. */
  46018. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46019. /**
  46020. * Gets wehter the submesh is ready to be used or not.
  46021. * @param defines the list of "defines" to update.
  46022. * @param scene defines the scene the material belongs to.
  46023. * @param engine defines the engine the material belongs to.
  46024. * @param disableBumpMap defines wether the material disables bump or not.
  46025. * @returns - boolean indicating that the submesh is ready or not.
  46026. */
  46027. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46028. /**
  46029. * Checks to see if a texture is used in the material.
  46030. * @param defines the list of "defines" to update.
  46031. * @param scene defines the scene to the material belongs to.
  46032. */
  46033. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46034. /**
  46035. * Binds the material data.
  46036. * @param uniformBuffer defines the Uniform buffer to fill in.
  46037. * @param scene defines the scene the material belongs to.
  46038. * @param engine defines the engine the material belongs to.
  46039. * @param disableBumpMap defines wether the material disables bump or not.
  46040. * @param isFrozen defines wether the material is frozen or not.
  46041. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46042. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46043. */
  46044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46045. /**
  46046. * Checks to see if a texture is used in the material.
  46047. * @param texture - Base texture to use.
  46048. * @returns - Boolean specifying if a texture is used in the material.
  46049. */
  46050. hasTexture(texture: BaseTexture): boolean;
  46051. /**
  46052. * Returns an array of the actively used textures.
  46053. * @param activeTextures Array of BaseTextures
  46054. */
  46055. getActiveTextures(activeTextures: BaseTexture[]): void;
  46056. /**
  46057. * Returns the animatable textures.
  46058. * @param animatables Array of animatable textures.
  46059. */
  46060. getAnimatables(animatables: IAnimatable[]): void;
  46061. /**
  46062. * Disposes the resources of the material.
  46063. * @param forceDisposeTextures - Forces the disposal of all textures.
  46064. */
  46065. dispose(forceDisposeTextures?: boolean): void;
  46066. /**
  46067. * Get the current class name of the texture useful for serialization or dynamic coding.
  46068. * @returns "PBRClearCoatConfiguration"
  46069. */
  46070. getClassName(): string;
  46071. /**
  46072. * Add fallbacks to the effect fallbacks list.
  46073. * @param defines defines the Base texture to use.
  46074. * @param fallbacks defines the current fallback list.
  46075. * @param currentRank defines the current fallback rank.
  46076. * @returns the new fallback rank.
  46077. */
  46078. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46079. /**
  46080. * Add the required uniforms to the current list.
  46081. * @param uniforms defines the current uniform list.
  46082. */
  46083. static AddUniforms(uniforms: string[]): void;
  46084. /**
  46085. * Add the required samplers to the current list.
  46086. * @param samplers defines the current sampler list.
  46087. */
  46088. static AddSamplers(samplers: string[]): void;
  46089. /**
  46090. * Add the required uniforms to the current buffer.
  46091. * @param uniformBuffer defines the current uniform buffer.
  46092. */
  46093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46094. /**
  46095. * Makes a duplicate of the current configuration into another one.
  46096. * @param clearCoatConfiguration define the config where to copy the info
  46097. */
  46098. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46099. /**
  46100. * Serializes this clear coat configuration.
  46101. * @returns - An object with the serialized config.
  46102. */
  46103. serialize(): any;
  46104. /**
  46105. * Parses a anisotropy Configuration from a serialized object.
  46106. * @param source - Serialized object.
  46107. * @param scene Defines the scene we are parsing for
  46108. * @param rootUrl Defines the rootUrl to load from
  46109. */
  46110. parse(source: any, scene: Scene, rootUrl: string): void;
  46111. }
  46112. }
  46113. declare module BABYLON {
  46114. /**
  46115. * @hidden
  46116. */
  46117. export interface IMaterialAnisotropicDefines {
  46118. ANISOTROPIC: boolean;
  46119. ANISOTROPIC_TEXTURE: boolean;
  46120. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46121. MAINUV1: boolean;
  46122. _areTexturesDirty: boolean;
  46123. _needUVs: boolean;
  46124. }
  46125. /**
  46126. * Define the code related to the anisotropic parameters of the pbr material.
  46127. */
  46128. export class PBRAnisotropicConfiguration {
  46129. private _isEnabled;
  46130. /**
  46131. * Defines if the anisotropy is enabled in the material.
  46132. */
  46133. isEnabled: boolean;
  46134. /**
  46135. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46136. */
  46137. intensity: number;
  46138. /**
  46139. * Defines if the effect is along the tangents, bitangents or in between.
  46140. * By default, the effect is "strectching" the highlights along the tangents.
  46141. */
  46142. direction: Vector2;
  46143. private _texture;
  46144. /**
  46145. * Stores the anisotropy values in a texture.
  46146. * rg is direction (like normal from -1 to 1)
  46147. * b is a intensity
  46148. */
  46149. texture: Nullable<BaseTexture>;
  46150. /** @hidden */
  46151. private _internalMarkAllSubMeshesAsTexturesDirty;
  46152. /** @hidden */
  46153. _markAllSubMeshesAsTexturesDirty(): void;
  46154. /**
  46155. * Instantiate a new istance of anisotropy configuration.
  46156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46157. */
  46158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46159. /**
  46160. * Specifies that the submesh is ready to be used.
  46161. * @param defines the list of "defines" to update.
  46162. * @param scene defines the scene the material belongs to.
  46163. * @returns - boolean indicating that the submesh is ready or not.
  46164. */
  46165. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46166. /**
  46167. * Checks to see if a texture is used in the material.
  46168. * @param defines the list of "defines" to update.
  46169. * @param mesh the mesh we are preparing the defines for.
  46170. * @param scene defines the scene the material belongs to.
  46171. */
  46172. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46173. /**
  46174. * Binds the material data.
  46175. * @param uniformBuffer defines the Uniform buffer to fill in.
  46176. * @param scene defines the scene the material belongs to.
  46177. * @param isFrozen defines wether the material is frozen or not.
  46178. */
  46179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46180. /**
  46181. * Checks to see if a texture is used in the material.
  46182. * @param texture - Base texture to use.
  46183. * @returns - Boolean specifying if a texture is used in the material.
  46184. */
  46185. hasTexture(texture: BaseTexture): boolean;
  46186. /**
  46187. * Returns an array of the actively used textures.
  46188. * @param activeTextures Array of BaseTextures
  46189. */
  46190. getActiveTextures(activeTextures: BaseTexture[]): void;
  46191. /**
  46192. * Returns the animatable textures.
  46193. * @param animatables Array of animatable textures.
  46194. */
  46195. getAnimatables(animatables: IAnimatable[]): void;
  46196. /**
  46197. * Disposes the resources of the material.
  46198. * @param forceDisposeTextures - Forces the disposal of all textures.
  46199. */
  46200. dispose(forceDisposeTextures?: boolean): void;
  46201. /**
  46202. * Get the current class name of the texture useful for serialization or dynamic coding.
  46203. * @returns "PBRAnisotropicConfiguration"
  46204. */
  46205. getClassName(): string;
  46206. /**
  46207. * Add fallbacks to the effect fallbacks list.
  46208. * @param defines defines the Base texture to use.
  46209. * @param fallbacks defines the current fallback list.
  46210. * @param currentRank defines the current fallback rank.
  46211. * @returns the new fallback rank.
  46212. */
  46213. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46214. /**
  46215. * Add the required uniforms to the current list.
  46216. * @param uniforms defines the current uniform list.
  46217. */
  46218. static AddUniforms(uniforms: string[]): void;
  46219. /**
  46220. * Add the required uniforms to the current buffer.
  46221. * @param uniformBuffer defines the current uniform buffer.
  46222. */
  46223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46224. /**
  46225. * Add the required samplers to the current list.
  46226. * @param samplers defines the current sampler list.
  46227. */
  46228. static AddSamplers(samplers: string[]): void;
  46229. /**
  46230. * Makes a duplicate of the current configuration into another one.
  46231. * @param anisotropicConfiguration define the config where to copy the info
  46232. */
  46233. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46234. /**
  46235. * Serializes this anisotropy configuration.
  46236. * @returns - An object with the serialized config.
  46237. */
  46238. serialize(): any;
  46239. /**
  46240. * Parses a anisotropy Configuration from a serialized object.
  46241. * @param source - Serialized object.
  46242. * @param scene Defines the scene we are parsing for
  46243. * @param rootUrl Defines the rootUrl to load from
  46244. */
  46245. parse(source: any, scene: Scene, rootUrl: string): void;
  46246. }
  46247. }
  46248. declare module BABYLON {
  46249. /**
  46250. * @hidden
  46251. */
  46252. export interface IMaterialBRDFDefines {
  46253. BRDF_V_HEIGHT_CORRELATED: boolean;
  46254. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46255. SPHERICAL_HARMONICS: boolean;
  46256. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46257. /** @hidden */
  46258. _areMiscDirty: boolean;
  46259. }
  46260. /**
  46261. * Define the code related to the BRDF parameters of the pbr material.
  46262. */
  46263. export class PBRBRDFConfiguration {
  46264. /**
  46265. * Default value used for the energy conservation.
  46266. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46267. */
  46268. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46269. /**
  46270. * Default value used for the Smith Visibility Height Correlated mode.
  46271. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46272. */
  46273. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46274. /**
  46275. * Default value used for the IBL diffuse part.
  46276. * This can help switching back to the polynomials mode globally which is a tiny bit
  46277. * less GPU intensive at the drawback of a lower quality.
  46278. */
  46279. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46280. /**
  46281. * Default value used for activating energy conservation for the specular workflow.
  46282. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46283. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46284. */
  46285. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46286. private _useEnergyConservation;
  46287. /**
  46288. * Defines if the material uses energy conservation.
  46289. */
  46290. useEnergyConservation: boolean;
  46291. private _useSmithVisibilityHeightCorrelated;
  46292. /**
  46293. * LEGACY Mode set to false
  46294. * Defines if the material uses height smith correlated visibility term.
  46295. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46296. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46297. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46298. * Not relying on height correlated will also disable energy conservation.
  46299. */
  46300. useSmithVisibilityHeightCorrelated: boolean;
  46301. private _useSphericalHarmonics;
  46302. /**
  46303. * LEGACY Mode set to false
  46304. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46305. * diffuse part of the IBL.
  46306. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46307. * to the ground truth.
  46308. */
  46309. useSphericalHarmonics: boolean;
  46310. private _useSpecularGlossinessInputEnergyConservation;
  46311. /**
  46312. * Defines if the material uses energy conservation, when the specular workflow is active.
  46313. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46314. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46315. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46316. */
  46317. useSpecularGlossinessInputEnergyConservation: boolean;
  46318. /** @hidden */
  46319. private _internalMarkAllSubMeshesAsMiscDirty;
  46320. /** @hidden */
  46321. _markAllSubMeshesAsMiscDirty(): void;
  46322. /**
  46323. * Instantiate a new istance of clear coat configuration.
  46324. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46325. */
  46326. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46327. /**
  46328. * Checks to see if a texture is used in the material.
  46329. * @param defines the list of "defines" to update.
  46330. */
  46331. prepareDefines(defines: IMaterialBRDFDefines): void;
  46332. /**
  46333. * Get the current class name of the texture useful for serialization or dynamic coding.
  46334. * @returns "PBRClearCoatConfiguration"
  46335. */
  46336. getClassName(): string;
  46337. /**
  46338. * Makes a duplicate of the current configuration into another one.
  46339. * @param brdfConfiguration define the config where to copy the info
  46340. */
  46341. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46342. /**
  46343. * Serializes this BRDF configuration.
  46344. * @returns - An object with the serialized config.
  46345. */
  46346. serialize(): any;
  46347. /**
  46348. * Parses a anisotropy Configuration from a serialized object.
  46349. * @param source - Serialized object.
  46350. * @param scene Defines the scene we are parsing for
  46351. * @param rootUrl Defines the rootUrl to load from
  46352. */
  46353. parse(source: any, scene: Scene, rootUrl: string): void;
  46354. }
  46355. }
  46356. declare module BABYLON {
  46357. /**
  46358. * @hidden
  46359. */
  46360. export interface IMaterialSheenDefines {
  46361. SHEEN: boolean;
  46362. SHEEN_TEXTURE: boolean;
  46363. SHEEN_TEXTUREDIRECTUV: number;
  46364. SHEEN_LINKWITHALBEDO: boolean;
  46365. /** @hidden */
  46366. _areTexturesDirty: boolean;
  46367. }
  46368. /**
  46369. * Define the code related to the Sheen parameters of the pbr material.
  46370. */
  46371. export class PBRSheenConfiguration {
  46372. private _isEnabled;
  46373. /**
  46374. * Defines if the material uses sheen.
  46375. */
  46376. isEnabled: boolean;
  46377. private _linkSheenWithAlbedo;
  46378. /**
  46379. * Defines if the sheen is linked to the sheen color.
  46380. */
  46381. linkSheenWithAlbedo: boolean;
  46382. /**
  46383. * Defines the sheen intensity.
  46384. */
  46385. intensity: number;
  46386. /**
  46387. * Defines the sheen color.
  46388. */
  46389. color: Color3;
  46390. private _texture;
  46391. /**
  46392. * Stores the sheen tint values in a texture.
  46393. * rgb is tint
  46394. * a is a intensity
  46395. */
  46396. texture: Nullable<BaseTexture>;
  46397. /** @hidden */
  46398. private _internalMarkAllSubMeshesAsTexturesDirty;
  46399. /** @hidden */
  46400. _markAllSubMeshesAsTexturesDirty(): void;
  46401. /**
  46402. * Instantiate a new istance of clear coat configuration.
  46403. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46404. */
  46405. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46406. /**
  46407. * Specifies that the submesh is ready to be used.
  46408. * @param defines the list of "defines" to update.
  46409. * @param scene defines the scene the material belongs to.
  46410. * @returns - boolean indicating that the submesh is ready or not.
  46411. */
  46412. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46413. /**
  46414. * Checks to see if a texture is used in the material.
  46415. * @param defines the list of "defines" to update.
  46416. * @param scene defines the scene the material belongs to.
  46417. */
  46418. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46419. /**
  46420. * Binds the material data.
  46421. * @param uniformBuffer defines the Uniform buffer to fill in.
  46422. * @param scene defines the scene the material belongs to.
  46423. * @param isFrozen defines wether the material is frozen or not.
  46424. */
  46425. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46426. /**
  46427. * Checks to see if a texture is used in the material.
  46428. * @param texture - Base texture to use.
  46429. * @returns - Boolean specifying if a texture is used in the material.
  46430. */
  46431. hasTexture(texture: BaseTexture): boolean;
  46432. /**
  46433. * Returns an array of the actively used textures.
  46434. * @param activeTextures Array of BaseTextures
  46435. */
  46436. getActiveTextures(activeTextures: BaseTexture[]): void;
  46437. /**
  46438. * Returns the animatable textures.
  46439. * @param animatables Array of animatable textures.
  46440. */
  46441. getAnimatables(animatables: IAnimatable[]): void;
  46442. /**
  46443. * Disposes the resources of the material.
  46444. * @param forceDisposeTextures - Forces the disposal of all textures.
  46445. */
  46446. dispose(forceDisposeTextures?: boolean): void;
  46447. /**
  46448. * Get the current class name of the texture useful for serialization or dynamic coding.
  46449. * @returns "PBRSheenConfiguration"
  46450. */
  46451. getClassName(): string;
  46452. /**
  46453. * Add fallbacks to the effect fallbacks list.
  46454. * @param defines defines the Base texture to use.
  46455. * @param fallbacks defines the current fallback list.
  46456. * @param currentRank defines the current fallback rank.
  46457. * @returns the new fallback rank.
  46458. */
  46459. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46460. /**
  46461. * Add the required uniforms to the current list.
  46462. * @param uniforms defines the current uniform list.
  46463. */
  46464. static AddUniforms(uniforms: string[]): void;
  46465. /**
  46466. * Add the required uniforms to the current buffer.
  46467. * @param uniformBuffer defines the current uniform buffer.
  46468. */
  46469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46470. /**
  46471. * Add the required samplers to the current list.
  46472. * @param samplers defines the current sampler list.
  46473. */
  46474. static AddSamplers(samplers: string[]): void;
  46475. /**
  46476. * Makes a duplicate of the current configuration into another one.
  46477. * @param sheenConfiguration define the config where to copy the info
  46478. */
  46479. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46480. /**
  46481. * Serializes this BRDF configuration.
  46482. * @returns - An object with the serialized config.
  46483. */
  46484. serialize(): any;
  46485. /**
  46486. * Parses a anisotropy Configuration from a serialized object.
  46487. * @param source - Serialized object.
  46488. * @param scene Defines the scene we are parsing for
  46489. * @param rootUrl Defines the rootUrl to load from
  46490. */
  46491. parse(source: any, scene: Scene, rootUrl: string): void;
  46492. }
  46493. }
  46494. declare module BABYLON {
  46495. /**
  46496. * @hidden
  46497. */
  46498. export interface IMaterialSubSurfaceDefines {
  46499. SUBSURFACE: boolean;
  46500. SS_REFRACTION: boolean;
  46501. SS_TRANSLUCENCY: boolean;
  46502. SS_SCATERRING: boolean;
  46503. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46504. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46505. SS_REFRACTIONMAP_3D: boolean;
  46506. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46507. SS_LODINREFRACTIONALPHA: boolean;
  46508. SS_GAMMAREFRACTION: boolean;
  46509. SS_RGBDREFRACTION: boolean;
  46510. SS_LINEARSPECULARREFRACTION: boolean;
  46511. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46512. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46513. /** @hidden */
  46514. _areTexturesDirty: boolean;
  46515. }
  46516. /**
  46517. * Define the code related to the sub surface parameters of the pbr material.
  46518. */
  46519. export class PBRSubSurfaceConfiguration {
  46520. private _isRefractionEnabled;
  46521. /**
  46522. * Defines if the refraction is enabled in the material.
  46523. */
  46524. isRefractionEnabled: boolean;
  46525. private _isTranslucencyEnabled;
  46526. /**
  46527. * Defines if the translucency is enabled in the material.
  46528. */
  46529. isTranslucencyEnabled: boolean;
  46530. private _isScatteringEnabled;
  46531. /**
  46532. * Defines the refraction intensity of the material.
  46533. * The refraction when enabled replaces the Diffuse part of the material.
  46534. * The intensity helps transitionning between diffuse and refraction.
  46535. */
  46536. refractionIntensity: number;
  46537. /**
  46538. * Defines the translucency intensity of the material.
  46539. * When translucency has been enabled, this defines how much of the "translucency"
  46540. * is addded to the diffuse part of the material.
  46541. */
  46542. translucencyIntensity: number;
  46543. /**
  46544. * Defines the scattering intensity of the material.
  46545. * When scattering has been enabled, this defines how much of the "scattered light"
  46546. * is addded to the diffuse part of the material.
  46547. */
  46548. scatteringIntensity: number;
  46549. private _thicknessTexture;
  46550. /**
  46551. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46552. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46553. * 0 would mean minimumThickness
  46554. * 1 would mean maximumThickness
  46555. * The other channels might be use as a mask to vary the different effects intensity.
  46556. */
  46557. thicknessTexture: Nullable<BaseTexture>;
  46558. private _refractionTexture;
  46559. /**
  46560. * Defines the texture to use for refraction.
  46561. */
  46562. refractionTexture: Nullable<BaseTexture>;
  46563. private _indexOfRefraction;
  46564. /**
  46565. * Defines the index of refraction used in the material.
  46566. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46567. */
  46568. indexOfRefraction: number;
  46569. private _invertRefractionY;
  46570. /**
  46571. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46572. */
  46573. invertRefractionY: boolean;
  46574. private _linkRefractionWithTransparency;
  46575. /**
  46576. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46577. * Materials half opaque for instance using refraction could benefit from this control.
  46578. */
  46579. linkRefractionWithTransparency: boolean;
  46580. /**
  46581. * Defines the minimum thickness stored in the thickness map.
  46582. * If no thickness map is defined, this value will be used to simulate thickness.
  46583. */
  46584. minimumThickness: number;
  46585. /**
  46586. * Defines the maximum thickness stored in the thickness map.
  46587. */
  46588. maximumThickness: number;
  46589. /**
  46590. * Defines the volume tint of the material.
  46591. * This is used for both translucency and scattering.
  46592. */
  46593. tintColor: Color3;
  46594. /**
  46595. * Defines the distance at which the tint color should be found in the media.
  46596. * This is used for refraction only.
  46597. */
  46598. tintColorAtDistance: number;
  46599. /**
  46600. * Defines how far each channel transmit through the media.
  46601. * It is defined as a color to simplify it selection.
  46602. */
  46603. diffusionDistance: Color3;
  46604. private _useMaskFromThicknessTexture;
  46605. /**
  46606. * Stores the intensity of the different subsurface effects in the thickness texture.
  46607. * * the green channel is the translucency intensity.
  46608. * * the blue channel is the scattering intensity.
  46609. * * the alpha channel is the refraction intensity.
  46610. */
  46611. useMaskFromThicknessTexture: boolean;
  46612. /** @hidden */
  46613. private _internalMarkAllSubMeshesAsTexturesDirty;
  46614. /** @hidden */
  46615. _markAllSubMeshesAsTexturesDirty(): void;
  46616. /**
  46617. * Instantiate a new istance of sub surface configuration.
  46618. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46619. */
  46620. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46621. /**
  46622. * Gets wehter the submesh is ready to be used or not.
  46623. * @param defines the list of "defines" to update.
  46624. * @param scene defines the scene the material belongs to.
  46625. * @returns - boolean indicating that the submesh is ready or not.
  46626. */
  46627. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46628. /**
  46629. * Checks to see if a texture is used in the material.
  46630. * @param defines the list of "defines" to update.
  46631. * @param scene defines the scene to the material belongs to.
  46632. */
  46633. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46634. /**
  46635. * Binds the material data.
  46636. * @param uniformBuffer defines the Uniform buffer to fill in.
  46637. * @param scene defines the scene the material belongs to.
  46638. * @param engine defines the engine the material belongs to.
  46639. * @param isFrozen defines wether the material is frozen or not.
  46640. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46641. */
  46642. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46643. /**
  46644. * Unbinds the material from the mesh.
  46645. * @param activeEffect defines the effect that should be unbound from.
  46646. * @returns true if unbound, otherwise false
  46647. */
  46648. unbind(activeEffect: Effect): boolean;
  46649. /**
  46650. * Returns the texture used for refraction or null if none is used.
  46651. * @param scene defines the scene the material belongs to.
  46652. * @returns - Refraction texture if present. If no refraction texture and refraction
  46653. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46654. */
  46655. private _getRefractionTexture;
  46656. /**
  46657. * Returns true if alpha blending should be disabled.
  46658. */
  46659. readonly disableAlphaBlending: boolean;
  46660. /**
  46661. * Fills the list of render target textures.
  46662. * @param renderTargets the list of render targets to update
  46663. */
  46664. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46665. /**
  46666. * Checks to see if a texture is used in the material.
  46667. * @param texture - Base texture to use.
  46668. * @returns - Boolean specifying if a texture is used in the material.
  46669. */
  46670. hasTexture(texture: BaseTexture): boolean;
  46671. /**
  46672. * Gets a boolean indicating that current material needs to register RTT
  46673. * @returns true if this uses a render target otherwise false.
  46674. */
  46675. hasRenderTargetTextures(): boolean;
  46676. /**
  46677. * Returns an array of the actively used textures.
  46678. * @param activeTextures Array of BaseTextures
  46679. */
  46680. getActiveTextures(activeTextures: BaseTexture[]): void;
  46681. /**
  46682. * Returns the animatable textures.
  46683. * @param animatables Array of animatable textures.
  46684. */
  46685. getAnimatables(animatables: IAnimatable[]): void;
  46686. /**
  46687. * Disposes the resources of the material.
  46688. * @param forceDisposeTextures - Forces the disposal of all textures.
  46689. */
  46690. dispose(forceDisposeTextures?: boolean): void;
  46691. /**
  46692. * Get the current class name of the texture useful for serialization or dynamic coding.
  46693. * @returns "PBRSubSurfaceConfiguration"
  46694. */
  46695. getClassName(): string;
  46696. /**
  46697. * Add fallbacks to the effect fallbacks list.
  46698. * @param defines defines the Base texture to use.
  46699. * @param fallbacks defines the current fallback list.
  46700. * @param currentRank defines the current fallback rank.
  46701. * @returns the new fallback rank.
  46702. */
  46703. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46704. /**
  46705. * Add the required uniforms to the current list.
  46706. * @param uniforms defines the current uniform list.
  46707. */
  46708. static AddUniforms(uniforms: string[]): void;
  46709. /**
  46710. * Add the required samplers to the current list.
  46711. * @param samplers defines the current sampler list.
  46712. */
  46713. static AddSamplers(samplers: string[]): void;
  46714. /**
  46715. * Add the required uniforms to the current buffer.
  46716. * @param uniformBuffer defines the current uniform buffer.
  46717. */
  46718. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46719. /**
  46720. * Makes a duplicate of the current configuration into another one.
  46721. * @param configuration define the config where to copy the info
  46722. */
  46723. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46724. /**
  46725. * Serializes this Sub Surface configuration.
  46726. * @returns - An object with the serialized config.
  46727. */
  46728. serialize(): any;
  46729. /**
  46730. * Parses a anisotropy Configuration from a serialized object.
  46731. * @param source - Serialized object.
  46732. * @param scene Defines the scene we are parsing for
  46733. * @param rootUrl Defines the rootUrl to load from
  46734. */
  46735. parse(source: any, scene: Scene, rootUrl: string): void;
  46736. }
  46737. }
  46738. declare module BABYLON {
  46739. /** @hidden */
  46740. export var pbrFragmentDeclaration: {
  46741. name: string;
  46742. shader: string;
  46743. };
  46744. }
  46745. declare module BABYLON {
  46746. /** @hidden */
  46747. export var pbrUboDeclaration: {
  46748. name: string;
  46749. shader: string;
  46750. };
  46751. }
  46752. declare module BABYLON {
  46753. /** @hidden */
  46754. export var pbrFragmentExtraDeclaration: {
  46755. name: string;
  46756. shader: string;
  46757. };
  46758. }
  46759. declare module BABYLON {
  46760. /** @hidden */
  46761. export var pbrFragmentSamplersDeclaration: {
  46762. name: string;
  46763. shader: string;
  46764. };
  46765. }
  46766. declare module BABYLON {
  46767. /** @hidden */
  46768. export var pbrHelperFunctions: {
  46769. name: string;
  46770. shader: string;
  46771. };
  46772. }
  46773. declare module BABYLON {
  46774. /** @hidden */
  46775. export var harmonicsFunctions: {
  46776. name: string;
  46777. shader: string;
  46778. };
  46779. }
  46780. declare module BABYLON {
  46781. /** @hidden */
  46782. export var pbrDirectLightingSetupFunctions: {
  46783. name: string;
  46784. shader: string;
  46785. };
  46786. }
  46787. declare module BABYLON {
  46788. /** @hidden */
  46789. export var pbrDirectLightingFalloffFunctions: {
  46790. name: string;
  46791. shader: string;
  46792. };
  46793. }
  46794. declare module BABYLON {
  46795. /** @hidden */
  46796. export var pbrBRDFFunctions: {
  46797. name: string;
  46798. shader: string;
  46799. };
  46800. }
  46801. declare module BABYLON {
  46802. /** @hidden */
  46803. export var pbrDirectLightingFunctions: {
  46804. name: string;
  46805. shader: string;
  46806. };
  46807. }
  46808. declare module BABYLON {
  46809. /** @hidden */
  46810. export var pbrIBLFunctions: {
  46811. name: string;
  46812. shader: string;
  46813. };
  46814. }
  46815. declare module BABYLON {
  46816. /** @hidden */
  46817. export var pbrDebug: {
  46818. name: string;
  46819. shader: string;
  46820. };
  46821. }
  46822. declare module BABYLON {
  46823. /** @hidden */
  46824. export var pbrPixelShader: {
  46825. name: string;
  46826. shader: string;
  46827. };
  46828. }
  46829. declare module BABYLON {
  46830. /** @hidden */
  46831. export var pbrVertexDeclaration: {
  46832. name: string;
  46833. shader: string;
  46834. };
  46835. }
  46836. declare module BABYLON {
  46837. /** @hidden */
  46838. export var pbrVertexShader: {
  46839. name: string;
  46840. shader: string;
  46841. };
  46842. }
  46843. declare module BABYLON {
  46844. /**
  46845. * Manages the defines for the PBR Material.
  46846. * @hidden
  46847. */
  46848. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46849. PBR: boolean;
  46850. MAINUV1: boolean;
  46851. MAINUV2: boolean;
  46852. UV1: boolean;
  46853. UV2: boolean;
  46854. ALBEDO: boolean;
  46855. ALBEDODIRECTUV: number;
  46856. VERTEXCOLOR: boolean;
  46857. AMBIENT: boolean;
  46858. AMBIENTDIRECTUV: number;
  46859. AMBIENTINGRAYSCALE: boolean;
  46860. OPACITY: boolean;
  46861. VERTEXALPHA: boolean;
  46862. OPACITYDIRECTUV: number;
  46863. OPACITYRGB: boolean;
  46864. ALPHATEST: boolean;
  46865. DEPTHPREPASS: boolean;
  46866. ALPHABLEND: boolean;
  46867. ALPHAFROMALBEDO: boolean;
  46868. ALPHATESTVALUE: string;
  46869. SPECULAROVERALPHA: boolean;
  46870. RADIANCEOVERALPHA: boolean;
  46871. ALPHAFRESNEL: boolean;
  46872. LINEARALPHAFRESNEL: boolean;
  46873. PREMULTIPLYALPHA: boolean;
  46874. EMISSIVE: boolean;
  46875. EMISSIVEDIRECTUV: number;
  46876. REFLECTIVITY: boolean;
  46877. REFLECTIVITYDIRECTUV: number;
  46878. SPECULARTERM: boolean;
  46879. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46880. MICROSURFACEAUTOMATIC: boolean;
  46881. LODBASEDMICROSFURACE: boolean;
  46882. MICROSURFACEMAP: boolean;
  46883. MICROSURFACEMAPDIRECTUV: number;
  46884. METALLICWORKFLOW: boolean;
  46885. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46886. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46887. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46888. AOSTOREINMETALMAPRED: boolean;
  46889. ENVIRONMENTBRDF: boolean;
  46890. ENVIRONMENTBRDF_RGBD: boolean;
  46891. NORMAL: boolean;
  46892. TANGENT: boolean;
  46893. BUMP: boolean;
  46894. BUMPDIRECTUV: number;
  46895. OBJECTSPACE_NORMALMAP: boolean;
  46896. PARALLAX: boolean;
  46897. PARALLAXOCCLUSION: boolean;
  46898. NORMALXYSCALE: boolean;
  46899. LIGHTMAP: boolean;
  46900. LIGHTMAPDIRECTUV: number;
  46901. USELIGHTMAPASSHADOWMAP: boolean;
  46902. GAMMALIGHTMAP: boolean;
  46903. RGBDLIGHTMAP: boolean;
  46904. REFLECTION: boolean;
  46905. REFLECTIONMAP_3D: boolean;
  46906. REFLECTIONMAP_SPHERICAL: boolean;
  46907. REFLECTIONMAP_PLANAR: boolean;
  46908. REFLECTIONMAP_CUBIC: boolean;
  46909. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46910. REFLECTIONMAP_PROJECTION: boolean;
  46911. REFLECTIONMAP_SKYBOX: boolean;
  46912. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46913. REFLECTIONMAP_EXPLICIT: boolean;
  46914. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46915. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46916. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46917. INVERTCUBICMAP: boolean;
  46918. USESPHERICALFROMREFLECTIONMAP: boolean;
  46919. USEIRRADIANCEMAP: boolean;
  46920. SPHERICAL_HARMONICS: boolean;
  46921. USESPHERICALINVERTEX: boolean;
  46922. REFLECTIONMAP_OPPOSITEZ: boolean;
  46923. LODINREFLECTIONALPHA: boolean;
  46924. GAMMAREFLECTION: boolean;
  46925. RGBDREFLECTION: boolean;
  46926. LINEARSPECULARREFLECTION: boolean;
  46927. RADIANCEOCCLUSION: boolean;
  46928. HORIZONOCCLUSION: boolean;
  46929. INSTANCES: boolean;
  46930. NUM_BONE_INFLUENCERS: number;
  46931. BonesPerMesh: number;
  46932. BONETEXTURE: boolean;
  46933. NONUNIFORMSCALING: boolean;
  46934. MORPHTARGETS: boolean;
  46935. MORPHTARGETS_NORMAL: boolean;
  46936. MORPHTARGETS_TANGENT: boolean;
  46937. MORPHTARGETS_UV: boolean;
  46938. NUM_MORPH_INFLUENCERS: number;
  46939. IMAGEPROCESSING: boolean;
  46940. VIGNETTE: boolean;
  46941. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46942. VIGNETTEBLENDMODEOPAQUE: boolean;
  46943. TONEMAPPING: boolean;
  46944. TONEMAPPING_ACES: boolean;
  46945. CONTRAST: boolean;
  46946. COLORCURVES: boolean;
  46947. COLORGRADING: boolean;
  46948. COLORGRADING3D: boolean;
  46949. SAMPLER3DGREENDEPTH: boolean;
  46950. SAMPLER3DBGRMAP: boolean;
  46951. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46952. EXPOSURE: boolean;
  46953. MULTIVIEW: boolean;
  46954. USEPHYSICALLIGHTFALLOFF: boolean;
  46955. USEGLTFLIGHTFALLOFF: boolean;
  46956. TWOSIDEDLIGHTING: boolean;
  46957. SHADOWFLOAT: boolean;
  46958. CLIPPLANE: boolean;
  46959. CLIPPLANE2: boolean;
  46960. CLIPPLANE3: boolean;
  46961. CLIPPLANE4: boolean;
  46962. POINTSIZE: boolean;
  46963. FOG: boolean;
  46964. LOGARITHMICDEPTH: boolean;
  46965. FORCENORMALFORWARD: boolean;
  46966. SPECULARAA: boolean;
  46967. CLEARCOAT: boolean;
  46968. CLEARCOAT_DEFAULTIOR: boolean;
  46969. CLEARCOAT_TEXTURE: boolean;
  46970. CLEARCOAT_TEXTUREDIRECTUV: number;
  46971. CLEARCOAT_BUMP: boolean;
  46972. CLEARCOAT_BUMPDIRECTUV: number;
  46973. CLEARCOAT_TINT: boolean;
  46974. CLEARCOAT_TINT_TEXTURE: boolean;
  46975. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46976. ANISOTROPIC: boolean;
  46977. ANISOTROPIC_TEXTURE: boolean;
  46978. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46979. BRDF_V_HEIGHT_CORRELATED: boolean;
  46980. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46981. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46982. SHEEN: boolean;
  46983. SHEEN_TEXTURE: boolean;
  46984. SHEEN_TEXTUREDIRECTUV: number;
  46985. SHEEN_LINKWITHALBEDO: boolean;
  46986. SUBSURFACE: boolean;
  46987. SS_REFRACTION: boolean;
  46988. SS_TRANSLUCENCY: boolean;
  46989. SS_SCATERRING: boolean;
  46990. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46991. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46992. SS_REFRACTIONMAP_3D: boolean;
  46993. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46994. SS_LODINREFRACTIONALPHA: boolean;
  46995. SS_GAMMAREFRACTION: boolean;
  46996. SS_RGBDREFRACTION: boolean;
  46997. SS_LINEARSPECULARREFRACTION: boolean;
  46998. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46999. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47000. UNLIT: boolean;
  47001. DEBUGMODE: number;
  47002. /**
  47003. * Initializes the PBR Material defines.
  47004. */
  47005. constructor();
  47006. /**
  47007. * Resets the PBR Material defines.
  47008. */
  47009. reset(): void;
  47010. }
  47011. /**
  47012. * The Physically based material base class of BJS.
  47013. *
  47014. * This offers the main features of a standard PBR material.
  47015. * For more information, please refer to the documentation :
  47016. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47017. */
  47018. export abstract class PBRBaseMaterial extends PushMaterial {
  47019. /**
  47020. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47021. */
  47022. static readonly PBRMATERIAL_OPAQUE: number;
  47023. /**
  47024. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47025. */
  47026. static readonly PBRMATERIAL_ALPHATEST: number;
  47027. /**
  47028. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47029. */
  47030. static readonly PBRMATERIAL_ALPHABLEND: number;
  47031. /**
  47032. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47033. * They are also discarded below the alpha cutoff threshold to improve performances.
  47034. */
  47035. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47036. /**
  47037. * Defines the default value of how much AO map is occluding the analytical lights
  47038. * (point spot...).
  47039. */
  47040. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47041. /**
  47042. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47043. */
  47044. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47045. /**
  47046. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47047. * to enhance interoperability with other engines.
  47048. */
  47049. static readonly LIGHTFALLOFF_GLTF: number;
  47050. /**
  47051. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47052. * to enhance interoperability with other materials.
  47053. */
  47054. static readonly LIGHTFALLOFF_STANDARD: number;
  47055. /**
  47056. * Intensity of the direct lights e.g. the four lights available in your scene.
  47057. * This impacts both the direct diffuse and specular highlights.
  47058. */
  47059. protected _directIntensity: number;
  47060. /**
  47061. * Intensity of the emissive part of the material.
  47062. * This helps controlling the emissive effect without modifying the emissive color.
  47063. */
  47064. protected _emissiveIntensity: number;
  47065. /**
  47066. * Intensity of the environment e.g. how much the environment will light the object
  47067. * either through harmonics for rough material or through the refelction for shiny ones.
  47068. */
  47069. protected _environmentIntensity: number;
  47070. /**
  47071. * This is a special control allowing the reduction of the specular highlights coming from the
  47072. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47073. */
  47074. protected _specularIntensity: number;
  47075. /**
  47076. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47077. */
  47078. private _lightingInfos;
  47079. /**
  47080. * Debug Control allowing disabling the bump map on this material.
  47081. */
  47082. protected _disableBumpMap: boolean;
  47083. /**
  47084. * AKA Diffuse Texture in standard nomenclature.
  47085. */
  47086. protected _albedoTexture: Nullable<BaseTexture>;
  47087. /**
  47088. * AKA Occlusion Texture in other nomenclature.
  47089. */
  47090. protected _ambientTexture: Nullable<BaseTexture>;
  47091. /**
  47092. * AKA Occlusion Texture Intensity in other nomenclature.
  47093. */
  47094. protected _ambientTextureStrength: number;
  47095. /**
  47096. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47097. * 1 means it completely occludes it
  47098. * 0 mean it has no impact
  47099. */
  47100. protected _ambientTextureImpactOnAnalyticalLights: number;
  47101. /**
  47102. * Stores the alpha values in a texture.
  47103. */
  47104. protected _opacityTexture: Nullable<BaseTexture>;
  47105. /**
  47106. * Stores the reflection values in a texture.
  47107. */
  47108. protected _reflectionTexture: Nullable<BaseTexture>;
  47109. /**
  47110. * Stores the emissive values in a texture.
  47111. */
  47112. protected _emissiveTexture: Nullable<BaseTexture>;
  47113. /**
  47114. * AKA Specular texture in other nomenclature.
  47115. */
  47116. protected _reflectivityTexture: Nullable<BaseTexture>;
  47117. /**
  47118. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47119. */
  47120. protected _metallicTexture: Nullable<BaseTexture>;
  47121. /**
  47122. * Specifies the metallic scalar of the metallic/roughness workflow.
  47123. * Can also be used to scale the metalness values of the metallic texture.
  47124. */
  47125. protected _metallic: Nullable<number>;
  47126. /**
  47127. * Specifies the roughness scalar of the metallic/roughness workflow.
  47128. * Can also be used to scale the roughness values of the metallic texture.
  47129. */
  47130. protected _roughness: Nullable<number>;
  47131. /**
  47132. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47133. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47134. */
  47135. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47136. /**
  47137. * Stores surface normal data used to displace a mesh in a texture.
  47138. */
  47139. protected _bumpTexture: Nullable<BaseTexture>;
  47140. /**
  47141. * Stores the pre-calculated light information of a mesh in a texture.
  47142. */
  47143. protected _lightmapTexture: Nullable<BaseTexture>;
  47144. /**
  47145. * The color of a material in ambient lighting.
  47146. */
  47147. protected _ambientColor: Color3;
  47148. /**
  47149. * AKA Diffuse Color in other nomenclature.
  47150. */
  47151. protected _albedoColor: Color3;
  47152. /**
  47153. * AKA Specular Color in other nomenclature.
  47154. */
  47155. protected _reflectivityColor: Color3;
  47156. /**
  47157. * The color applied when light is reflected from a material.
  47158. */
  47159. protected _reflectionColor: Color3;
  47160. /**
  47161. * The color applied when light is emitted from a material.
  47162. */
  47163. protected _emissiveColor: Color3;
  47164. /**
  47165. * AKA Glossiness in other nomenclature.
  47166. */
  47167. protected _microSurface: number;
  47168. /**
  47169. * Specifies that the material will use the light map as a show map.
  47170. */
  47171. protected _useLightmapAsShadowmap: boolean;
  47172. /**
  47173. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47174. * makes the reflect vector face the model (under horizon).
  47175. */
  47176. protected _useHorizonOcclusion: boolean;
  47177. /**
  47178. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47179. * too much the area relying on ambient texture to define their ambient occlusion.
  47180. */
  47181. protected _useRadianceOcclusion: boolean;
  47182. /**
  47183. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47184. */
  47185. protected _useAlphaFromAlbedoTexture: boolean;
  47186. /**
  47187. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47188. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47189. */
  47190. protected _useSpecularOverAlpha: boolean;
  47191. /**
  47192. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47193. */
  47194. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47195. /**
  47196. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47197. */
  47198. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47199. /**
  47200. * Specifies if the metallic texture contains the roughness information in its green channel.
  47201. */
  47202. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47203. /**
  47204. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47205. */
  47206. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47207. /**
  47208. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47209. */
  47210. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47211. /**
  47212. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47213. */
  47214. protected _useAmbientInGrayScale: boolean;
  47215. /**
  47216. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47217. * The material will try to infer what glossiness each pixel should be.
  47218. */
  47219. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47220. /**
  47221. * Defines the falloff type used in this material.
  47222. * It by default is Physical.
  47223. */
  47224. protected _lightFalloff: number;
  47225. /**
  47226. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47227. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47228. */
  47229. protected _useRadianceOverAlpha: boolean;
  47230. /**
  47231. * Allows using an object space normal map (instead of tangent space).
  47232. */
  47233. protected _useObjectSpaceNormalMap: boolean;
  47234. /**
  47235. * Allows using the bump map in parallax mode.
  47236. */
  47237. protected _useParallax: boolean;
  47238. /**
  47239. * Allows using the bump map in parallax occlusion mode.
  47240. */
  47241. protected _useParallaxOcclusion: boolean;
  47242. /**
  47243. * Controls the scale bias of the parallax mode.
  47244. */
  47245. protected _parallaxScaleBias: number;
  47246. /**
  47247. * If sets to true, disables all the lights affecting the material.
  47248. */
  47249. protected _disableLighting: boolean;
  47250. /**
  47251. * Number of Simultaneous lights allowed on the material.
  47252. */
  47253. protected _maxSimultaneousLights: number;
  47254. /**
  47255. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47256. */
  47257. protected _invertNormalMapX: boolean;
  47258. /**
  47259. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47260. */
  47261. protected _invertNormalMapY: boolean;
  47262. /**
  47263. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47264. */
  47265. protected _twoSidedLighting: boolean;
  47266. /**
  47267. * Defines the alpha limits in alpha test mode.
  47268. */
  47269. protected _alphaCutOff: number;
  47270. /**
  47271. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47272. */
  47273. protected _forceAlphaTest: boolean;
  47274. /**
  47275. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47276. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47277. */
  47278. protected _useAlphaFresnel: boolean;
  47279. /**
  47280. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47281. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47282. */
  47283. protected _useLinearAlphaFresnel: boolean;
  47284. /**
  47285. * The transparency mode of the material.
  47286. */
  47287. protected _transparencyMode: Nullable<number>;
  47288. /**
  47289. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47290. * from cos thetav and roughness:
  47291. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47292. */
  47293. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47294. /**
  47295. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47296. */
  47297. protected _forceIrradianceInFragment: boolean;
  47298. /**
  47299. * Force normal to face away from face.
  47300. */
  47301. protected _forceNormalForward: boolean;
  47302. /**
  47303. * Enables specular anti aliasing in the PBR shader.
  47304. * It will both interacts on the Geometry for analytical and IBL lighting.
  47305. * It also prefilter the roughness map based on the bump values.
  47306. */
  47307. protected _enableSpecularAntiAliasing: boolean;
  47308. /**
  47309. * Default configuration related to image processing available in the PBR Material.
  47310. */
  47311. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47312. /**
  47313. * Keep track of the image processing observer to allow dispose and replace.
  47314. */
  47315. private _imageProcessingObserver;
  47316. /**
  47317. * Attaches a new image processing configuration to the PBR Material.
  47318. * @param configuration
  47319. */
  47320. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47321. /**
  47322. * Stores the available render targets.
  47323. */
  47324. private _renderTargets;
  47325. /**
  47326. * Sets the global ambient color for the material used in lighting calculations.
  47327. */
  47328. private _globalAmbientColor;
  47329. /**
  47330. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47331. */
  47332. private _useLogarithmicDepth;
  47333. /**
  47334. * If set to true, no lighting calculations will be applied.
  47335. */
  47336. private _unlit;
  47337. private _debugMode;
  47338. /**
  47339. * @hidden
  47340. * This is reserved for the inspector.
  47341. * Defines the material debug mode.
  47342. * It helps seeing only some components of the material while troubleshooting.
  47343. */
  47344. debugMode: number;
  47345. /**
  47346. * @hidden
  47347. * This is reserved for the inspector.
  47348. * Specify from where on screen the debug mode should start.
  47349. * The value goes from -1 (full screen) to 1 (not visible)
  47350. * It helps with side by side comparison against the final render
  47351. * This defaults to -1
  47352. */
  47353. private debugLimit;
  47354. /**
  47355. * @hidden
  47356. * This is reserved for the inspector.
  47357. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47358. * You can use the factor to better multiply the final value.
  47359. */
  47360. private debugFactor;
  47361. /**
  47362. * Defines the clear coat layer parameters for the material.
  47363. */
  47364. readonly clearCoat: PBRClearCoatConfiguration;
  47365. /**
  47366. * Defines the anisotropic parameters for the material.
  47367. */
  47368. readonly anisotropy: PBRAnisotropicConfiguration;
  47369. /**
  47370. * Defines the BRDF parameters for the material.
  47371. */
  47372. readonly brdf: PBRBRDFConfiguration;
  47373. /**
  47374. * Defines the Sheen parameters for the material.
  47375. */
  47376. readonly sheen: PBRSheenConfiguration;
  47377. /**
  47378. * Defines the SubSurface parameters for the material.
  47379. */
  47380. readonly subSurface: PBRSubSurfaceConfiguration;
  47381. /**
  47382. * Custom callback helping to override the default shader used in the material.
  47383. */
  47384. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47385. protected _rebuildInParallel: boolean;
  47386. /**
  47387. * Instantiates a new PBRMaterial instance.
  47388. *
  47389. * @param name The material name
  47390. * @param scene The scene the material will be use in.
  47391. */
  47392. constructor(name: string, scene: Scene);
  47393. /**
  47394. * Gets a boolean indicating that current material needs to register RTT
  47395. */
  47396. readonly hasRenderTargetTextures: boolean;
  47397. /**
  47398. * Gets the name of the material class.
  47399. */
  47400. getClassName(): string;
  47401. /**
  47402. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47403. */
  47404. /**
  47405. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47406. */
  47407. useLogarithmicDepth: boolean;
  47408. /**
  47409. * Gets the current transparency mode.
  47410. */
  47411. /**
  47412. * Sets the transparency mode of the material.
  47413. *
  47414. * | Value | Type | Description |
  47415. * | ----- | ----------------------------------- | ----------- |
  47416. * | 0 | OPAQUE | |
  47417. * | 1 | ALPHATEST | |
  47418. * | 2 | ALPHABLEND | |
  47419. * | 3 | ALPHATESTANDBLEND | |
  47420. *
  47421. */
  47422. transparencyMode: Nullable<number>;
  47423. /**
  47424. * Returns true if alpha blending should be disabled.
  47425. */
  47426. private readonly _disableAlphaBlending;
  47427. /**
  47428. * Specifies whether or not this material should be rendered in alpha blend mode.
  47429. */
  47430. needAlphaBlending(): boolean;
  47431. /**
  47432. * Specifies if the mesh will require alpha blending.
  47433. * @param mesh - BJS mesh.
  47434. */
  47435. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47436. /**
  47437. * Specifies whether or not this material should be rendered in alpha test mode.
  47438. */
  47439. needAlphaTesting(): boolean;
  47440. /**
  47441. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47442. */
  47443. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47444. /**
  47445. * Gets the texture used for the alpha test.
  47446. */
  47447. getAlphaTestTexture(): Nullable<BaseTexture>;
  47448. /**
  47449. * Specifies that the submesh is ready to be used.
  47450. * @param mesh - BJS mesh.
  47451. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47452. * @param useInstances - Specifies that instances should be used.
  47453. * @returns - boolean indicating that the submesh is ready or not.
  47454. */
  47455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47456. /**
  47457. * Specifies if the material uses metallic roughness workflow.
  47458. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47459. */
  47460. isMetallicWorkflow(): boolean;
  47461. private _prepareEffect;
  47462. private _prepareDefines;
  47463. /**
  47464. * Force shader compilation
  47465. */
  47466. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47467. clipPlane: boolean;
  47468. }>): void;
  47469. /**
  47470. * Initializes the uniform buffer layout for the shader.
  47471. */
  47472. buildUniformLayout(): void;
  47473. /**
  47474. * Unbinds the material from the mesh
  47475. */
  47476. unbind(): void;
  47477. /**
  47478. * Binds the submesh data.
  47479. * @param world - The world matrix.
  47480. * @param mesh - The BJS mesh.
  47481. * @param subMesh - A submesh of the BJS mesh.
  47482. */
  47483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47484. /**
  47485. * Returns the animatable textures.
  47486. * @returns - Array of animatable textures.
  47487. */
  47488. getAnimatables(): IAnimatable[];
  47489. /**
  47490. * Returns the texture used for reflections.
  47491. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47492. */
  47493. private _getReflectionTexture;
  47494. /**
  47495. * Returns an array of the actively used textures.
  47496. * @returns - Array of BaseTextures
  47497. */
  47498. getActiveTextures(): BaseTexture[];
  47499. /**
  47500. * Checks to see if a texture is used in the material.
  47501. * @param texture - Base texture to use.
  47502. * @returns - Boolean specifying if a texture is used in the material.
  47503. */
  47504. hasTexture(texture: BaseTexture): boolean;
  47505. /**
  47506. * Disposes the resources of the material.
  47507. * @param forceDisposeEffect - Forces the disposal of effects.
  47508. * @param forceDisposeTextures - Forces the disposal of all textures.
  47509. */
  47510. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47511. }
  47512. }
  47513. declare module BABYLON {
  47514. /**
  47515. * The Physically based material of BJS.
  47516. *
  47517. * This offers the main features of a standard PBR material.
  47518. * For more information, please refer to the documentation :
  47519. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47520. */
  47521. export class PBRMaterial extends PBRBaseMaterial {
  47522. /**
  47523. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47524. */
  47525. static readonly PBRMATERIAL_OPAQUE: number;
  47526. /**
  47527. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47528. */
  47529. static readonly PBRMATERIAL_ALPHATEST: number;
  47530. /**
  47531. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47532. */
  47533. static readonly PBRMATERIAL_ALPHABLEND: number;
  47534. /**
  47535. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47536. * They are also discarded below the alpha cutoff threshold to improve performances.
  47537. */
  47538. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47539. /**
  47540. * Defines the default value of how much AO map is occluding the analytical lights
  47541. * (point spot...).
  47542. */
  47543. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47544. /**
  47545. * Intensity of the direct lights e.g. the four lights available in your scene.
  47546. * This impacts both the direct diffuse and specular highlights.
  47547. */
  47548. directIntensity: number;
  47549. /**
  47550. * Intensity of the emissive part of the material.
  47551. * This helps controlling the emissive effect without modifying the emissive color.
  47552. */
  47553. emissiveIntensity: number;
  47554. /**
  47555. * Intensity of the environment e.g. how much the environment will light the object
  47556. * either through harmonics for rough material or through the refelction for shiny ones.
  47557. */
  47558. environmentIntensity: number;
  47559. /**
  47560. * This is a special control allowing the reduction of the specular highlights coming from the
  47561. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47562. */
  47563. specularIntensity: number;
  47564. /**
  47565. * Debug Control allowing disabling the bump map on this material.
  47566. */
  47567. disableBumpMap: boolean;
  47568. /**
  47569. * AKA Diffuse Texture in standard nomenclature.
  47570. */
  47571. albedoTexture: BaseTexture;
  47572. /**
  47573. * AKA Occlusion Texture in other nomenclature.
  47574. */
  47575. ambientTexture: BaseTexture;
  47576. /**
  47577. * AKA Occlusion Texture Intensity in other nomenclature.
  47578. */
  47579. ambientTextureStrength: number;
  47580. /**
  47581. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47582. * 1 means it completely occludes it
  47583. * 0 mean it has no impact
  47584. */
  47585. ambientTextureImpactOnAnalyticalLights: number;
  47586. /**
  47587. * Stores the alpha values in a texture.
  47588. */
  47589. opacityTexture: BaseTexture;
  47590. /**
  47591. * Stores the reflection values in a texture.
  47592. */
  47593. reflectionTexture: Nullable<BaseTexture>;
  47594. /**
  47595. * Stores the emissive values in a texture.
  47596. */
  47597. emissiveTexture: BaseTexture;
  47598. /**
  47599. * AKA Specular texture in other nomenclature.
  47600. */
  47601. reflectivityTexture: BaseTexture;
  47602. /**
  47603. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47604. */
  47605. metallicTexture: BaseTexture;
  47606. /**
  47607. * Specifies the metallic scalar of the metallic/roughness workflow.
  47608. * Can also be used to scale the metalness values of the metallic texture.
  47609. */
  47610. metallic: Nullable<number>;
  47611. /**
  47612. * Specifies the roughness scalar of the metallic/roughness workflow.
  47613. * Can also be used to scale the roughness values of the metallic texture.
  47614. */
  47615. roughness: Nullable<number>;
  47616. /**
  47617. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47618. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47619. */
  47620. microSurfaceTexture: BaseTexture;
  47621. /**
  47622. * Stores surface normal data used to displace a mesh in a texture.
  47623. */
  47624. bumpTexture: BaseTexture;
  47625. /**
  47626. * Stores the pre-calculated light information of a mesh in a texture.
  47627. */
  47628. lightmapTexture: BaseTexture;
  47629. /**
  47630. * Stores the refracted light information in a texture.
  47631. */
  47632. refractionTexture: Nullable<BaseTexture>;
  47633. /**
  47634. * The color of a material in ambient lighting.
  47635. */
  47636. ambientColor: Color3;
  47637. /**
  47638. * AKA Diffuse Color in other nomenclature.
  47639. */
  47640. albedoColor: Color3;
  47641. /**
  47642. * AKA Specular Color in other nomenclature.
  47643. */
  47644. reflectivityColor: Color3;
  47645. /**
  47646. * The color reflected from the material.
  47647. */
  47648. reflectionColor: Color3;
  47649. /**
  47650. * The color emitted from the material.
  47651. */
  47652. emissiveColor: Color3;
  47653. /**
  47654. * AKA Glossiness in other nomenclature.
  47655. */
  47656. microSurface: number;
  47657. /**
  47658. * source material index of refraction (IOR)' / 'destination material IOR.
  47659. */
  47660. indexOfRefraction: number;
  47661. /**
  47662. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47663. */
  47664. invertRefractionY: boolean;
  47665. /**
  47666. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47667. * Materials half opaque for instance using refraction could benefit from this control.
  47668. */
  47669. linkRefractionWithTransparency: boolean;
  47670. /**
  47671. * If true, the light map contains occlusion information instead of lighting info.
  47672. */
  47673. useLightmapAsShadowmap: boolean;
  47674. /**
  47675. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47676. */
  47677. useAlphaFromAlbedoTexture: boolean;
  47678. /**
  47679. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47680. */
  47681. forceAlphaTest: boolean;
  47682. /**
  47683. * Defines the alpha limits in alpha test mode.
  47684. */
  47685. alphaCutOff: number;
  47686. /**
  47687. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47688. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47689. */
  47690. useSpecularOverAlpha: boolean;
  47691. /**
  47692. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47693. */
  47694. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47695. /**
  47696. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47697. */
  47698. useRoughnessFromMetallicTextureAlpha: boolean;
  47699. /**
  47700. * Specifies if the metallic texture contains the roughness information in its green channel.
  47701. */
  47702. useRoughnessFromMetallicTextureGreen: boolean;
  47703. /**
  47704. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47705. */
  47706. useMetallnessFromMetallicTextureBlue: boolean;
  47707. /**
  47708. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47709. */
  47710. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47711. /**
  47712. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47713. */
  47714. useAmbientInGrayScale: boolean;
  47715. /**
  47716. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47717. * The material will try to infer what glossiness each pixel should be.
  47718. */
  47719. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47720. /**
  47721. * BJS is using an harcoded light falloff based on a manually sets up range.
  47722. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47723. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47724. */
  47725. /**
  47726. * BJS is using an harcoded light falloff based on a manually sets up range.
  47727. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47728. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47729. */
  47730. usePhysicalLightFalloff: boolean;
  47731. /**
  47732. * In order to support the falloff compatibility with gltf, a special mode has been added
  47733. * to reproduce the gltf light falloff.
  47734. */
  47735. /**
  47736. * In order to support the falloff compatibility with gltf, a special mode has been added
  47737. * to reproduce the gltf light falloff.
  47738. */
  47739. useGLTFLightFalloff: boolean;
  47740. /**
  47741. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47742. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47743. */
  47744. useRadianceOverAlpha: boolean;
  47745. /**
  47746. * Allows using an object space normal map (instead of tangent space).
  47747. */
  47748. useObjectSpaceNormalMap: boolean;
  47749. /**
  47750. * Allows using the bump map in parallax mode.
  47751. */
  47752. useParallax: boolean;
  47753. /**
  47754. * Allows using the bump map in parallax occlusion mode.
  47755. */
  47756. useParallaxOcclusion: boolean;
  47757. /**
  47758. * Controls the scale bias of the parallax mode.
  47759. */
  47760. parallaxScaleBias: number;
  47761. /**
  47762. * If sets to true, disables all the lights affecting the material.
  47763. */
  47764. disableLighting: boolean;
  47765. /**
  47766. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47767. */
  47768. forceIrradianceInFragment: boolean;
  47769. /**
  47770. * Number of Simultaneous lights allowed on the material.
  47771. */
  47772. maxSimultaneousLights: number;
  47773. /**
  47774. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47775. */
  47776. invertNormalMapX: boolean;
  47777. /**
  47778. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47779. */
  47780. invertNormalMapY: boolean;
  47781. /**
  47782. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47783. */
  47784. twoSidedLighting: boolean;
  47785. /**
  47786. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47787. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47788. */
  47789. useAlphaFresnel: boolean;
  47790. /**
  47791. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47792. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47793. */
  47794. useLinearAlphaFresnel: boolean;
  47795. /**
  47796. * Let user defines the brdf lookup texture used for IBL.
  47797. * A default 8bit version is embedded but you could point at :
  47798. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47799. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47800. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47801. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47802. */
  47803. environmentBRDFTexture: Nullable<BaseTexture>;
  47804. /**
  47805. * Force normal to face away from face.
  47806. */
  47807. forceNormalForward: boolean;
  47808. /**
  47809. * Enables specular anti aliasing in the PBR shader.
  47810. * It will both interacts on the Geometry for analytical and IBL lighting.
  47811. * It also prefilter the roughness map based on the bump values.
  47812. */
  47813. enableSpecularAntiAliasing: boolean;
  47814. /**
  47815. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47816. * makes the reflect vector face the model (under horizon).
  47817. */
  47818. useHorizonOcclusion: boolean;
  47819. /**
  47820. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47821. * too much the area relying on ambient texture to define their ambient occlusion.
  47822. */
  47823. useRadianceOcclusion: boolean;
  47824. /**
  47825. * If set to true, no lighting calculations will be applied.
  47826. */
  47827. unlit: boolean;
  47828. /**
  47829. * Gets the image processing configuration used either in this material.
  47830. */
  47831. /**
  47832. * Sets the Default image processing configuration used either in the this material.
  47833. *
  47834. * If sets to null, the scene one is in use.
  47835. */
  47836. imageProcessingConfiguration: ImageProcessingConfiguration;
  47837. /**
  47838. * Gets wether the color curves effect is enabled.
  47839. */
  47840. /**
  47841. * Sets wether the color curves effect is enabled.
  47842. */
  47843. cameraColorCurvesEnabled: boolean;
  47844. /**
  47845. * Gets wether the color grading effect is enabled.
  47846. */
  47847. /**
  47848. * Gets wether the color grading effect is enabled.
  47849. */
  47850. cameraColorGradingEnabled: boolean;
  47851. /**
  47852. * Gets wether tonemapping is enabled or not.
  47853. */
  47854. /**
  47855. * Sets wether tonemapping is enabled or not
  47856. */
  47857. cameraToneMappingEnabled: boolean;
  47858. /**
  47859. * The camera exposure used on this material.
  47860. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47861. * This corresponds to a photographic exposure.
  47862. */
  47863. /**
  47864. * The camera exposure used on this material.
  47865. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47866. * This corresponds to a photographic exposure.
  47867. */
  47868. cameraExposure: number;
  47869. /**
  47870. * Gets The camera contrast used on this material.
  47871. */
  47872. /**
  47873. * Sets The camera contrast used on this material.
  47874. */
  47875. cameraContrast: number;
  47876. /**
  47877. * Gets the Color Grading 2D Lookup Texture.
  47878. */
  47879. /**
  47880. * Sets the Color Grading 2D Lookup Texture.
  47881. */
  47882. cameraColorGradingTexture: Nullable<BaseTexture>;
  47883. /**
  47884. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47885. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47886. * 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;
  47887. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47888. */
  47889. /**
  47890. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47891. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47892. * 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;
  47893. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47894. */
  47895. cameraColorCurves: Nullable<ColorCurves>;
  47896. /**
  47897. * Instantiates a new PBRMaterial instance.
  47898. *
  47899. * @param name The material name
  47900. * @param scene The scene the material will be use in.
  47901. */
  47902. constructor(name: string, scene: Scene);
  47903. /**
  47904. * Returns the name of this material class.
  47905. */
  47906. getClassName(): string;
  47907. /**
  47908. * Makes a duplicate of the current material.
  47909. * @param name - name to use for the new material.
  47910. */
  47911. clone(name: string): PBRMaterial;
  47912. /**
  47913. * Serializes this PBR Material.
  47914. * @returns - An object with the serialized material.
  47915. */
  47916. serialize(): any;
  47917. /**
  47918. * Parses a PBR Material from a serialized object.
  47919. * @param source - Serialized object.
  47920. * @param scene - BJS scene instance.
  47921. * @param rootUrl - url for the scene object
  47922. * @returns - PBRMaterial
  47923. */
  47924. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47925. }
  47926. }
  47927. declare module BABYLON {
  47928. /**
  47929. * Direct draw surface info
  47930. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47931. */
  47932. export interface DDSInfo {
  47933. /**
  47934. * Width of the texture
  47935. */
  47936. width: number;
  47937. /**
  47938. * Width of the texture
  47939. */
  47940. height: number;
  47941. /**
  47942. * Number of Mipmaps for the texture
  47943. * @see https://en.wikipedia.org/wiki/Mipmap
  47944. */
  47945. mipmapCount: number;
  47946. /**
  47947. * If the textures format is a known fourCC format
  47948. * @see https://www.fourcc.org/
  47949. */
  47950. isFourCC: boolean;
  47951. /**
  47952. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47953. */
  47954. isRGB: boolean;
  47955. /**
  47956. * If the texture is a lumincance format
  47957. */
  47958. isLuminance: boolean;
  47959. /**
  47960. * If this is a cube texture
  47961. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47962. */
  47963. isCube: boolean;
  47964. /**
  47965. * If the texture is a compressed format eg. FOURCC_DXT1
  47966. */
  47967. isCompressed: boolean;
  47968. /**
  47969. * The dxgiFormat of the texture
  47970. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47971. */
  47972. dxgiFormat: number;
  47973. /**
  47974. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47975. */
  47976. textureType: number;
  47977. /**
  47978. * Sphericle polynomial created for the dds texture
  47979. */
  47980. sphericalPolynomial?: SphericalPolynomial;
  47981. }
  47982. /**
  47983. * Class used to provide DDS decompression tools
  47984. */
  47985. export class DDSTools {
  47986. /**
  47987. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47988. */
  47989. static StoreLODInAlphaChannel: boolean;
  47990. /**
  47991. * Gets DDS information from an array buffer
  47992. * @param arrayBuffer defines the array buffer to read data from
  47993. * @returns the DDS information
  47994. */
  47995. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47996. private static _FloatView;
  47997. private static _Int32View;
  47998. private static _ToHalfFloat;
  47999. private static _FromHalfFloat;
  48000. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48001. private static _GetHalfFloatRGBAArrayBuffer;
  48002. private static _GetFloatRGBAArrayBuffer;
  48003. private static _GetFloatAsUIntRGBAArrayBuffer;
  48004. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48005. private static _GetRGBAArrayBuffer;
  48006. private static _ExtractLongWordOrder;
  48007. private static _GetRGBArrayBuffer;
  48008. private static _GetLuminanceArrayBuffer;
  48009. /**
  48010. * Uploads DDS Levels to a Babylon Texture
  48011. * @hidden
  48012. */
  48013. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48014. }
  48015. interface Engine {
  48016. /**
  48017. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48018. * @param rootUrl defines the url where the file to load is located
  48019. * @param scene defines the current scene
  48020. * @param lodScale defines scale to apply to the mip map selection
  48021. * @param lodOffset defines offset to apply to the mip map selection
  48022. * @param onLoad defines an optional callback raised when the texture is loaded
  48023. * @param onError defines an optional callback raised if there is an issue to load the texture
  48024. * @param format defines the format of the data
  48025. * @param forcedExtension defines the extension to use to pick the right loader
  48026. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48027. * @returns the cube texture as an InternalTexture
  48028. */
  48029. 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;
  48030. }
  48031. }
  48032. declare module BABYLON {
  48033. /**
  48034. * Implementation of the DDS Texture Loader.
  48035. * @hidden
  48036. */
  48037. export class _DDSTextureLoader implements IInternalTextureLoader {
  48038. /**
  48039. * Defines wether the loader supports cascade loading the different faces.
  48040. */
  48041. readonly supportCascades: boolean;
  48042. /**
  48043. * This returns if the loader support the current file information.
  48044. * @param extension defines the file extension of the file being loaded
  48045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48046. * @param fallback defines the fallback internal texture if any
  48047. * @param isBase64 defines whether the texture is encoded as a base64
  48048. * @param isBuffer defines whether the texture data are stored as a buffer
  48049. * @returns true if the loader can load the specified file
  48050. */
  48051. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48052. /**
  48053. * Transform the url before loading if required.
  48054. * @param rootUrl the url of the texture
  48055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48056. * @returns the transformed texture
  48057. */
  48058. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48059. /**
  48060. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48061. * @param rootUrl the url of the texture
  48062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48063. * @returns the fallback texture
  48064. */
  48065. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48066. /**
  48067. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48068. * @param data contains the texture data
  48069. * @param texture defines the BabylonJS internal texture
  48070. * @param createPolynomials will be true if polynomials have been requested
  48071. * @param onLoad defines the callback to trigger once the texture is ready
  48072. * @param onError defines the callback to trigger in case of error
  48073. */
  48074. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48075. /**
  48076. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48077. * @param data contains the texture data
  48078. * @param texture defines the BabylonJS internal texture
  48079. * @param callback defines the method to call once ready to upload
  48080. */
  48081. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48082. }
  48083. }
  48084. declare module BABYLON {
  48085. /**
  48086. * Implementation of the ENV Texture Loader.
  48087. * @hidden
  48088. */
  48089. export class _ENVTextureLoader implements IInternalTextureLoader {
  48090. /**
  48091. * Defines wether the loader supports cascade loading the different faces.
  48092. */
  48093. readonly supportCascades: boolean;
  48094. /**
  48095. * This returns if the loader support the current file information.
  48096. * @param extension defines the file extension of the file being loaded
  48097. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48098. * @param fallback defines the fallback internal texture if any
  48099. * @param isBase64 defines whether the texture is encoded as a base64
  48100. * @param isBuffer defines whether the texture data are stored as a buffer
  48101. * @returns true if the loader can load the specified file
  48102. */
  48103. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48104. /**
  48105. * Transform the url before loading if required.
  48106. * @param rootUrl the url of the texture
  48107. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48108. * @returns the transformed texture
  48109. */
  48110. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48111. /**
  48112. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48113. * @param rootUrl the url of the texture
  48114. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48115. * @returns the fallback texture
  48116. */
  48117. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48118. /**
  48119. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48120. * @param data contains the texture data
  48121. * @param texture defines the BabylonJS internal texture
  48122. * @param createPolynomials will be true if polynomials have been requested
  48123. * @param onLoad defines the callback to trigger once the texture is ready
  48124. * @param onError defines the callback to trigger in case of error
  48125. */
  48126. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48127. /**
  48128. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48129. * @param data contains the texture data
  48130. * @param texture defines the BabylonJS internal texture
  48131. * @param callback defines the method to call once ready to upload
  48132. */
  48133. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48134. }
  48135. }
  48136. declare module BABYLON {
  48137. /**
  48138. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48139. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48140. */
  48141. export class KhronosTextureContainer {
  48142. /** contents of the KTX container file */
  48143. arrayBuffer: any;
  48144. private static HEADER_LEN;
  48145. private static COMPRESSED_2D;
  48146. private static COMPRESSED_3D;
  48147. private static TEX_2D;
  48148. private static TEX_3D;
  48149. /**
  48150. * Gets the openGL type
  48151. */
  48152. glType: number;
  48153. /**
  48154. * Gets the openGL type size
  48155. */
  48156. glTypeSize: number;
  48157. /**
  48158. * Gets the openGL format
  48159. */
  48160. glFormat: number;
  48161. /**
  48162. * Gets the openGL internal format
  48163. */
  48164. glInternalFormat: number;
  48165. /**
  48166. * Gets the base internal format
  48167. */
  48168. glBaseInternalFormat: number;
  48169. /**
  48170. * Gets image width in pixel
  48171. */
  48172. pixelWidth: number;
  48173. /**
  48174. * Gets image height in pixel
  48175. */
  48176. pixelHeight: number;
  48177. /**
  48178. * Gets image depth in pixels
  48179. */
  48180. pixelDepth: number;
  48181. /**
  48182. * Gets the number of array elements
  48183. */
  48184. numberOfArrayElements: number;
  48185. /**
  48186. * Gets the number of faces
  48187. */
  48188. numberOfFaces: number;
  48189. /**
  48190. * Gets the number of mipmap levels
  48191. */
  48192. numberOfMipmapLevels: number;
  48193. /**
  48194. * Gets the bytes of key value data
  48195. */
  48196. bytesOfKeyValueData: number;
  48197. /**
  48198. * Gets the load type
  48199. */
  48200. loadType: number;
  48201. /**
  48202. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48203. */
  48204. isInvalid: boolean;
  48205. /**
  48206. * Creates a new KhronosTextureContainer
  48207. * @param arrayBuffer contents of the KTX container file
  48208. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48209. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48210. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48211. */
  48212. constructor(
  48213. /** contents of the KTX container file */
  48214. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48215. /**
  48216. * Uploads KTX content to a Babylon Texture.
  48217. * It is assumed that the texture has already been created & is currently bound
  48218. * @hidden
  48219. */
  48220. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48221. private _upload2DCompressedLevels;
  48222. }
  48223. }
  48224. declare module BABYLON {
  48225. /**
  48226. * Implementation of the KTX Texture Loader.
  48227. * @hidden
  48228. */
  48229. export class _KTXTextureLoader implements IInternalTextureLoader {
  48230. /**
  48231. * Defines wether the loader supports cascade loading the different faces.
  48232. */
  48233. readonly supportCascades: boolean;
  48234. /**
  48235. * This returns if the loader support the current file information.
  48236. * @param extension defines the file extension of the file being loaded
  48237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48238. * @param fallback defines the fallback internal texture if any
  48239. * @param isBase64 defines whether the texture is encoded as a base64
  48240. * @param isBuffer defines whether the texture data are stored as a buffer
  48241. * @returns true if the loader can load the specified file
  48242. */
  48243. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48244. /**
  48245. * Transform the url before loading if required.
  48246. * @param rootUrl the url of the texture
  48247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48248. * @returns the transformed texture
  48249. */
  48250. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48251. /**
  48252. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48253. * @param rootUrl the url of the texture
  48254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48255. * @returns the fallback texture
  48256. */
  48257. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48258. /**
  48259. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48260. * @param data contains the texture data
  48261. * @param texture defines the BabylonJS internal texture
  48262. * @param createPolynomials will be true if polynomials have been requested
  48263. * @param onLoad defines the callback to trigger once the texture is ready
  48264. * @param onError defines the callback to trigger in case of error
  48265. */
  48266. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48267. /**
  48268. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48269. * @param data contains the texture data
  48270. * @param texture defines the BabylonJS internal texture
  48271. * @param callback defines the method to call once ready to upload
  48272. */
  48273. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48274. }
  48275. }
  48276. declare module BABYLON {
  48277. /**
  48278. * Options for the default xr helper
  48279. */
  48280. export class WebXRDefaultExperienceOptions {
  48281. /**
  48282. * Floor meshes that should be used for teleporting
  48283. */
  48284. floorMeshes: Array<AbstractMesh>;
  48285. }
  48286. /**
  48287. * Default experience which provides a similar setup to the previous webVRExperience
  48288. */
  48289. export class WebXRDefaultExperience {
  48290. /**
  48291. * Base experience
  48292. */
  48293. baseExperience: WebXRExperienceHelper;
  48294. /**
  48295. * Input experience extension
  48296. */
  48297. input: WebXRInput;
  48298. /**
  48299. * Loads the controller models
  48300. */
  48301. controllerModelLoader: WebXRControllerModelLoader;
  48302. /**
  48303. * Enables laser pointer and selection
  48304. */
  48305. pointerSelection: WebXRControllerPointerSelection;
  48306. /**
  48307. * Enables teleportation
  48308. */
  48309. teleportation: WebXRControllerTeleportation;
  48310. /**
  48311. * Enables ui for enetering/exiting xr
  48312. */
  48313. enterExitUI: WebXREnterExitUI;
  48314. /**
  48315. * Default output canvas xr should render to
  48316. */
  48317. outputCanvas: WebXRManagedOutputCanvas;
  48318. /**
  48319. * Creates the default xr experience
  48320. * @param scene scene
  48321. * @param options options for basic configuration
  48322. * @returns resulting WebXRDefaultExperience
  48323. */
  48324. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48325. private constructor();
  48326. /**
  48327. * DIsposes of the experience helper
  48328. */
  48329. dispose(): void;
  48330. }
  48331. }
  48332. declare module BABYLON {
  48333. /** @hidden */
  48334. export var _forceSceneHelpersToBundle: boolean;
  48335. interface Scene {
  48336. /**
  48337. * Creates a default light for the scene.
  48338. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48339. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48340. */
  48341. createDefaultLight(replace?: boolean): void;
  48342. /**
  48343. * Creates a default camera for the scene.
  48344. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48345. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48346. * @param replace has default false, when true replaces the active camera in the scene
  48347. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48348. */
  48349. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48350. /**
  48351. * Creates a default camera and a default light.
  48352. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48353. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48354. * @param replace has the default false, when true replaces the active camera/light in the scene
  48355. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48356. */
  48357. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48358. /**
  48359. * Creates a new sky box
  48360. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48361. * @param environmentTexture defines the texture to use as environment texture
  48362. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48363. * @param scale defines the overall scale of the skybox
  48364. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48365. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48366. * @returns a new mesh holding the sky box
  48367. */
  48368. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48369. /**
  48370. * Creates a new environment
  48371. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48372. * @param options defines the options you can use to configure the environment
  48373. * @returns the new EnvironmentHelper
  48374. */
  48375. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48376. /**
  48377. * Creates a new VREXperienceHelper
  48378. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48379. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48380. * @returns a new VREXperienceHelper
  48381. */
  48382. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48383. /**
  48384. * Creates a new WebXRDefaultExperience
  48385. * @see http://doc.babylonjs.com/how_to/webxr
  48386. * @param options experience options
  48387. * @returns a promise for a new WebXRDefaultExperience
  48388. */
  48389. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48390. }
  48391. }
  48392. declare module BABYLON {
  48393. /**
  48394. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48395. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48396. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48397. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48398. */
  48399. export class VideoDome extends TransformNode {
  48400. /**
  48401. * Define the video source as a Monoscopic panoramic 360 video.
  48402. */
  48403. static readonly MODE_MONOSCOPIC: number;
  48404. /**
  48405. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48406. */
  48407. static readonly MODE_TOPBOTTOM: number;
  48408. /**
  48409. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48410. */
  48411. static readonly MODE_SIDEBYSIDE: number;
  48412. private _halfDome;
  48413. private _useDirectMapping;
  48414. /**
  48415. * The video texture being displayed on the sphere
  48416. */
  48417. protected _videoTexture: VideoTexture;
  48418. /**
  48419. * Gets the video texture being displayed on the sphere
  48420. */
  48421. readonly videoTexture: VideoTexture;
  48422. /**
  48423. * The skybox material
  48424. */
  48425. protected _material: BackgroundMaterial;
  48426. /**
  48427. * The surface used for the skybox
  48428. */
  48429. protected _mesh: Mesh;
  48430. /**
  48431. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48432. */
  48433. private _halfDomeMask;
  48434. /**
  48435. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48436. * Also see the options.resolution property.
  48437. */
  48438. fovMultiplier: number;
  48439. private _videoMode;
  48440. /**
  48441. * Gets or set the current video mode for the video. It can be:
  48442. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48443. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48444. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48445. */
  48446. videoMode: number;
  48447. /**
  48448. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48449. *
  48450. */
  48451. /**
  48452. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48453. */
  48454. halfDome: boolean;
  48455. /**
  48456. * Oberserver used in Stereoscopic VR Mode.
  48457. */
  48458. private _onBeforeCameraRenderObserver;
  48459. /**
  48460. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48461. * @param name Element's name, child elements will append suffixes for their own names.
  48462. * @param urlsOrVideo defines the url(s) or the video element to use
  48463. * @param options An object containing optional or exposed sub element properties
  48464. */
  48465. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48466. resolution?: number;
  48467. clickToPlay?: boolean;
  48468. autoPlay?: boolean;
  48469. loop?: boolean;
  48470. size?: number;
  48471. poster?: string;
  48472. faceForward?: boolean;
  48473. useDirectMapping?: boolean;
  48474. halfDomeMode?: boolean;
  48475. }, scene: Scene);
  48476. private _changeVideoMode;
  48477. /**
  48478. * Releases resources associated with this node.
  48479. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48480. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48481. */
  48482. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48483. }
  48484. }
  48485. declare module BABYLON {
  48486. /**
  48487. * This class can be used to get instrumentation data from a Babylon engine
  48488. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48489. */
  48490. export class EngineInstrumentation implements IDisposable {
  48491. /**
  48492. * Define the instrumented engine.
  48493. */
  48494. engine: Engine;
  48495. private _captureGPUFrameTime;
  48496. private _gpuFrameTimeToken;
  48497. private _gpuFrameTime;
  48498. private _captureShaderCompilationTime;
  48499. private _shaderCompilationTime;
  48500. private _onBeginFrameObserver;
  48501. private _onEndFrameObserver;
  48502. private _onBeforeShaderCompilationObserver;
  48503. private _onAfterShaderCompilationObserver;
  48504. /**
  48505. * Gets the perf counter used for GPU frame time
  48506. */
  48507. readonly gpuFrameTimeCounter: PerfCounter;
  48508. /**
  48509. * Gets the GPU frame time capture status
  48510. */
  48511. /**
  48512. * Enable or disable the GPU frame time capture
  48513. */
  48514. captureGPUFrameTime: boolean;
  48515. /**
  48516. * Gets the perf counter used for shader compilation time
  48517. */
  48518. readonly shaderCompilationTimeCounter: PerfCounter;
  48519. /**
  48520. * Gets the shader compilation time capture status
  48521. */
  48522. /**
  48523. * Enable or disable the shader compilation time capture
  48524. */
  48525. captureShaderCompilationTime: boolean;
  48526. /**
  48527. * Instantiates a new engine instrumentation.
  48528. * This class can be used to get instrumentation data from a Babylon engine
  48529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48530. * @param engine Defines the engine to instrument
  48531. */
  48532. constructor(
  48533. /**
  48534. * Define the instrumented engine.
  48535. */
  48536. engine: Engine);
  48537. /**
  48538. * Dispose and release associated resources.
  48539. */
  48540. dispose(): void;
  48541. }
  48542. }
  48543. declare module BABYLON {
  48544. /**
  48545. * This class can be used to get instrumentation data from a Babylon engine
  48546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48547. */
  48548. export class SceneInstrumentation implements IDisposable {
  48549. /**
  48550. * Defines the scene to instrument
  48551. */
  48552. scene: Scene;
  48553. private _captureActiveMeshesEvaluationTime;
  48554. private _activeMeshesEvaluationTime;
  48555. private _captureRenderTargetsRenderTime;
  48556. private _renderTargetsRenderTime;
  48557. private _captureFrameTime;
  48558. private _frameTime;
  48559. private _captureRenderTime;
  48560. private _renderTime;
  48561. private _captureInterFrameTime;
  48562. private _interFrameTime;
  48563. private _captureParticlesRenderTime;
  48564. private _particlesRenderTime;
  48565. private _captureSpritesRenderTime;
  48566. private _spritesRenderTime;
  48567. private _capturePhysicsTime;
  48568. private _physicsTime;
  48569. private _captureAnimationsTime;
  48570. private _animationsTime;
  48571. private _captureCameraRenderTime;
  48572. private _cameraRenderTime;
  48573. private _onBeforeActiveMeshesEvaluationObserver;
  48574. private _onAfterActiveMeshesEvaluationObserver;
  48575. private _onBeforeRenderTargetsRenderObserver;
  48576. private _onAfterRenderTargetsRenderObserver;
  48577. private _onAfterRenderObserver;
  48578. private _onBeforeDrawPhaseObserver;
  48579. private _onAfterDrawPhaseObserver;
  48580. private _onBeforeAnimationsObserver;
  48581. private _onBeforeParticlesRenderingObserver;
  48582. private _onAfterParticlesRenderingObserver;
  48583. private _onBeforeSpritesRenderingObserver;
  48584. private _onAfterSpritesRenderingObserver;
  48585. private _onBeforePhysicsObserver;
  48586. private _onAfterPhysicsObserver;
  48587. private _onAfterAnimationsObserver;
  48588. private _onBeforeCameraRenderObserver;
  48589. private _onAfterCameraRenderObserver;
  48590. /**
  48591. * Gets the perf counter used for active meshes evaluation time
  48592. */
  48593. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48594. /**
  48595. * Gets the active meshes evaluation time capture status
  48596. */
  48597. /**
  48598. * Enable or disable the active meshes evaluation time capture
  48599. */
  48600. captureActiveMeshesEvaluationTime: boolean;
  48601. /**
  48602. * Gets the perf counter used for render targets render time
  48603. */
  48604. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48605. /**
  48606. * Gets the render targets render time capture status
  48607. */
  48608. /**
  48609. * Enable or disable the render targets render time capture
  48610. */
  48611. captureRenderTargetsRenderTime: boolean;
  48612. /**
  48613. * Gets the perf counter used for particles render time
  48614. */
  48615. readonly particlesRenderTimeCounter: PerfCounter;
  48616. /**
  48617. * Gets the particles render time capture status
  48618. */
  48619. /**
  48620. * Enable or disable the particles render time capture
  48621. */
  48622. captureParticlesRenderTime: boolean;
  48623. /**
  48624. * Gets the perf counter used for sprites render time
  48625. */
  48626. readonly spritesRenderTimeCounter: PerfCounter;
  48627. /**
  48628. * Gets the sprites render time capture status
  48629. */
  48630. /**
  48631. * Enable or disable the sprites render time capture
  48632. */
  48633. captureSpritesRenderTime: boolean;
  48634. /**
  48635. * Gets the perf counter used for physics time
  48636. */
  48637. readonly physicsTimeCounter: PerfCounter;
  48638. /**
  48639. * Gets the physics time capture status
  48640. */
  48641. /**
  48642. * Enable or disable the physics time capture
  48643. */
  48644. capturePhysicsTime: boolean;
  48645. /**
  48646. * Gets the perf counter used for animations time
  48647. */
  48648. readonly animationsTimeCounter: PerfCounter;
  48649. /**
  48650. * Gets the animations time capture status
  48651. */
  48652. /**
  48653. * Enable or disable the animations time capture
  48654. */
  48655. captureAnimationsTime: boolean;
  48656. /**
  48657. * Gets the perf counter used for frame time capture
  48658. */
  48659. readonly frameTimeCounter: PerfCounter;
  48660. /**
  48661. * Gets the frame time capture status
  48662. */
  48663. /**
  48664. * Enable or disable the frame time capture
  48665. */
  48666. captureFrameTime: boolean;
  48667. /**
  48668. * Gets the perf counter used for inter-frames time capture
  48669. */
  48670. readonly interFrameTimeCounter: PerfCounter;
  48671. /**
  48672. * Gets the inter-frames time capture status
  48673. */
  48674. /**
  48675. * Enable or disable the inter-frames time capture
  48676. */
  48677. captureInterFrameTime: boolean;
  48678. /**
  48679. * Gets the perf counter used for render time capture
  48680. */
  48681. readonly renderTimeCounter: PerfCounter;
  48682. /**
  48683. * Gets the render time capture status
  48684. */
  48685. /**
  48686. * Enable or disable the render time capture
  48687. */
  48688. captureRenderTime: boolean;
  48689. /**
  48690. * Gets the perf counter used for camera render time capture
  48691. */
  48692. readonly cameraRenderTimeCounter: PerfCounter;
  48693. /**
  48694. * Gets the camera render time capture status
  48695. */
  48696. /**
  48697. * Enable or disable the camera render time capture
  48698. */
  48699. captureCameraRenderTime: boolean;
  48700. /**
  48701. * Gets the perf counter used for draw calls
  48702. */
  48703. readonly drawCallsCounter: PerfCounter;
  48704. /**
  48705. * Instantiates a new scene instrumentation.
  48706. * This class can be used to get instrumentation data from a Babylon engine
  48707. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48708. * @param scene Defines the scene to instrument
  48709. */
  48710. constructor(
  48711. /**
  48712. * Defines the scene to instrument
  48713. */
  48714. scene: Scene);
  48715. /**
  48716. * Dispose and release associated resources.
  48717. */
  48718. dispose(): void;
  48719. }
  48720. }
  48721. declare module BABYLON {
  48722. /** @hidden */
  48723. export var glowMapGenerationPixelShader: {
  48724. name: string;
  48725. shader: string;
  48726. };
  48727. }
  48728. declare module BABYLON {
  48729. /** @hidden */
  48730. export var glowMapGenerationVertexShader: {
  48731. name: string;
  48732. shader: string;
  48733. };
  48734. }
  48735. declare module BABYLON {
  48736. /**
  48737. * Effect layer options. This helps customizing the behaviour
  48738. * of the effect layer.
  48739. */
  48740. export interface IEffectLayerOptions {
  48741. /**
  48742. * Multiplication factor apply to the canvas size to compute the render target size
  48743. * used to generated the objects (the smaller the faster).
  48744. */
  48745. mainTextureRatio: number;
  48746. /**
  48747. * Enforces a fixed size texture to ensure effect stability across devices.
  48748. */
  48749. mainTextureFixedSize?: number;
  48750. /**
  48751. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48752. */
  48753. alphaBlendingMode: number;
  48754. /**
  48755. * The camera attached to the layer.
  48756. */
  48757. camera: Nullable<Camera>;
  48758. /**
  48759. * The rendering group to draw the layer in.
  48760. */
  48761. renderingGroupId: number;
  48762. }
  48763. /**
  48764. * The effect layer Helps adding post process effect blended with the main pass.
  48765. *
  48766. * This can be for instance use to generate glow or higlight effects on the scene.
  48767. *
  48768. * The effect layer class can not be used directly and is intented to inherited from to be
  48769. * customized per effects.
  48770. */
  48771. export abstract class EffectLayer {
  48772. private _vertexBuffers;
  48773. private _indexBuffer;
  48774. private _cachedDefines;
  48775. private _effectLayerMapGenerationEffect;
  48776. private _effectLayerOptions;
  48777. private _mergeEffect;
  48778. protected _scene: Scene;
  48779. protected _engine: Engine;
  48780. protected _maxSize: number;
  48781. protected _mainTextureDesiredSize: ISize;
  48782. protected _mainTexture: RenderTargetTexture;
  48783. protected _shouldRender: boolean;
  48784. protected _postProcesses: PostProcess[];
  48785. protected _textures: BaseTexture[];
  48786. protected _emissiveTextureAndColor: {
  48787. texture: Nullable<BaseTexture>;
  48788. color: Color4;
  48789. };
  48790. /**
  48791. * The name of the layer
  48792. */
  48793. name: string;
  48794. /**
  48795. * The clear color of the texture used to generate the glow map.
  48796. */
  48797. neutralColor: Color4;
  48798. /**
  48799. * Specifies wether the highlight layer is enabled or not.
  48800. */
  48801. isEnabled: boolean;
  48802. /**
  48803. * Gets the camera attached to the layer.
  48804. */
  48805. readonly camera: Nullable<Camera>;
  48806. /**
  48807. * Gets the rendering group id the layer should render in.
  48808. */
  48809. renderingGroupId: number;
  48810. /**
  48811. * An event triggered when the effect layer has been disposed.
  48812. */
  48813. onDisposeObservable: Observable<EffectLayer>;
  48814. /**
  48815. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48816. */
  48817. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48818. /**
  48819. * An event triggered when the generated texture is being merged in the scene.
  48820. */
  48821. onBeforeComposeObservable: Observable<EffectLayer>;
  48822. /**
  48823. * An event triggered when the generated texture has been merged in the scene.
  48824. */
  48825. onAfterComposeObservable: Observable<EffectLayer>;
  48826. /**
  48827. * An event triggered when the efffect layer changes its size.
  48828. */
  48829. onSizeChangedObservable: Observable<EffectLayer>;
  48830. /** @hidden */
  48831. static _SceneComponentInitialization: (scene: Scene) => void;
  48832. /**
  48833. * Instantiates a new effect Layer and references it in the scene.
  48834. * @param name The name of the layer
  48835. * @param scene The scene to use the layer in
  48836. */
  48837. constructor(
  48838. /** The Friendly of the effect in the scene */
  48839. name: string, scene: Scene);
  48840. /**
  48841. * Get the effect name of the layer.
  48842. * @return The effect name
  48843. */
  48844. abstract getEffectName(): string;
  48845. /**
  48846. * Checks for the readiness of the element composing the layer.
  48847. * @param subMesh the mesh to check for
  48848. * @param useInstances specify wether or not to use instances to render the mesh
  48849. * @return true if ready otherwise, false
  48850. */
  48851. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48852. /**
  48853. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48854. * @returns true if the effect requires stencil during the main canvas render pass.
  48855. */
  48856. abstract needStencil(): boolean;
  48857. /**
  48858. * Create the merge effect. This is the shader use to blit the information back
  48859. * to the main canvas at the end of the scene rendering.
  48860. * @returns The effect containing the shader used to merge the effect on the main canvas
  48861. */
  48862. protected abstract _createMergeEffect(): Effect;
  48863. /**
  48864. * Creates the render target textures and post processes used in the effect layer.
  48865. */
  48866. protected abstract _createTextureAndPostProcesses(): void;
  48867. /**
  48868. * Implementation specific of rendering the generating effect on the main canvas.
  48869. * @param effect The effect used to render through
  48870. */
  48871. protected abstract _internalRender(effect: Effect): void;
  48872. /**
  48873. * Sets the required values for both the emissive texture and and the main color.
  48874. */
  48875. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48876. /**
  48877. * Free any resources and references associated to a mesh.
  48878. * Internal use
  48879. * @param mesh The mesh to free.
  48880. */
  48881. abstract _disposeMesh(mesh: Mesh): void;
  48882. /**
  48883. * Serializes this layer (Glow or Highlight for example)
  48884. * @returns a serialized layer object
  48885. */
  48886. abstract serialize?(): any;
  48887. /**
  48888. * Initializes the effect layer with the required options.
  48889. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48890. */
  48891. protected _init(options: Partial<IEffectLayerOptions>): void;
  48892. /**
  48893. * Generates the index buffer of the full screen quad blending to the main canvas.
  48894. */
  48895. private _generateIndexBuffer;
  48896. /**
  48897. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48898. */
  48899. private _generateVertexBuffer;
  48900. /**
  48901. * Sets the main texture desired size which is the closest power of two
  48902. * of the engine canvas size.
  48903. */
  48904. private _setMainTextureSize;
  48905. /**
  48906. * Creates the main texture for the effect layer.
  48907. */
  48908. protected _createMainTexture(): void;
  48909. /**
  48910. * Adds specific effects defines.
  48911. * @param defines The defines to add specifics to.
  48912. */
  48913. protected _addCustomEffectDefines(defines: string[]): void;
  48914. /**
  48915. * Checks for the readiness of the element composing the layer.
  48916. * @param subMesh the mesh to check for
  48917. * @param useInstances specify wether or not to use instances to render the mesh
  48918. * @param emissiveTexture the associated emissive texture used to generate the glow
  48919. * @return true if ready otherwise, false
  48920. */
  48921. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48922. /**
  48923. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48924. */
  48925. render(): void;
  48926. /**
  48927. * Determine if a given mesh will be used in the current effect.
  48928. * @param mesh mesh to test
  48929. * @returns true if the mesh will be used
  48930. */
  48931. hasMesh(mesh: AbstractMesh): boolean;
  48932. /**
  48933. * Returns true if the layer contains information to display, otherwise false.
  48934. * @returns true if the glow layer should be rendered
  48935. */
  48936. shouldRender(): boolean;
  48937. /**
  48938. * Returns true if the mesh should render, otherwise false.
  48939. * @param mesh The mesh to render
  48940. * @returns true if it should render otherwise false
  48941. */
  48942. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48943. /**
  48944. * Returns true if the mesh can be rendered, otherwise false.
  48945. * @param mesh The mesh to render
  48946. * @param material The material used on the mesh
  48947. * @returns true if it can be rendered otherwise false
  48948. */
  48949. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48950. /**
  48951. * Returns true if the mesh should render, otherwise false.
  48952. * @param mesh The mesh to render
  48953. * @returns true if it should render otherwise false
  48954. */
  48955. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48956. /**
  48957. * Renders the submesh passed in parameter to the generation map.
  48958. */
  48959. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48960. /**
  48961. * Rebuild the required buffers.
  48962. * @hidden Internal use only.
  48963. */
  48964. _rebuild(): void;
  48965. /**
  48966. * Dispose only the render target textures and post process.
  48967. */
  48968. private _disposeTextureAndPostProcesses;
  48969. /**
  48970. * Dispose the highlight layer and free resources.
  48971. */
  48972. dispose(): void;
  48973. /**
  48974. * Gets the class name of the effect layer
  48975. * @returns the string with the class name of the effect layer
  48976. */
  48977. getClassName(): string;
  48978. /**
  48979. * Creates an effect layer from parsed effect layer data
  48980. * @param parsedEffectLayer defines effect layer data
  48981. * @param scene defines the current scene
  48982. * @param rootUrl defines the root URL containing the effect layer information
  48983. * @returns a parsed effect Layer
  48984. */
  48985. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48986. }
  48987. }
  48988. declare module BABYLON {
  48989. interface AbstractScene {
  48990. /**
  48991. * The list of effect layers (highlights/glow) added to the scene
  48992. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48993. * @see http://doc.babylonjs.com/how_to/glow_layer
  48994. */
  48995. effectLayers: Array<EffectLayer>;
  48996. /**
  48997. * Removes the given effect layer from this scene.
  48998. * @param toRemove defines the effect layer to remove
  48999. * @returns the index of the removed effect layer
  49000. */
  49001. removeEffectLayer(toRemove: EffectLayer): number;
  49002. /**
  49003. * Adds the given effect layer to this scene
  49004. * @param newEffectLayer defines the effect layer to add
  49005. */
  49006. addEffectLayer(newEffectLayer: EffectLayer): void;
  49007. }
  49008. /**
  49009. * Defines the layer scene component responsible to manage any effect layers
  49010. * in a given scene.
  49011. */
  49012. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49013. /**
  49014. * The component name helpfull to identify the component in the list of scene components.
  49015. */
  49016. readonly name: string;
  49017. /**
  49018. * The scene the component belongs to.
  49019. */
  49020. scene: Scene;
  49021. private _engine;
  49022. private _renderEffects;
  49023. private _needStencil;
  49024. private _previousStencilState;
  49025. /**
  49026. * Creates a new instance of the component for the given scene
  49027. * @param scene Defines the scene to register the component in
  49028. */
  49029. constructor(scene: Scene);
  49030. /**
  49031. * Registers the component in a given scene
  49032. */
  49033. register(): void;
  49034. /**
  49035. * Rebuilds the elements related to this component in case of
  49036. * context lost for instance.
  49037. */
  49038. rebuild(): void;
  49039. /**
  49040. * Serializes the component data to the specified json object
  49041. * @param serializationObject The object to serialize to
  49042. */
  49043. serialize(serializationObject: any): void;
  49044. /**
  49045. * Adds all the elements from the container to the scene
  49046. * @param container the container holding the elements
  49047. */
  49048. addFromContainer(container: AbstractScene): void;
  49049. /**
  49050. * Removes all the elements in the container from the scene
  49051. * @param container contains the elements to remove
  49052. * @param dispose if the removed element should be disposed (default: false)
  49053. */
  49054. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49055. /**
  49056. * Disposes the component and the associated ressources.
  49057. */
  49058. dispose(): void;
  49059. private _isReadyForMesh;
  49060. private _renderMainTexture;
  49061. private _setStencil;
  49062. private _setStencilBack;
  49063. private _draw;
  49064. private _drawCamera;
  49065. private _drawRenderingGroup;
  49066. }
  49067. }
  49068. declare module BABYLON {
  49069. /** @hidden */
  49070. export var glowMapMergePixelShader: {
  49071. name: string;
  49072. shader: string;
  49073. };
  49074. }
  49075. declare module BABYLON {
  49076. /** @hidden */
  49077. export var glowMapMergeVertexShader: {
  49078. name: string;
  49079. shader: string;
  49080. };
  49081. }
  49082. declare module BABYLON {
  49083. interface AbstractScene {
  49084. /**
  49085. * Return a the first highlight layer of the scene with a given name.
  49086. * @param name The name of the highlight layer to look for.
  49087. * @return The highlight layer if found otherwise null.
  49088. */
  49089. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49090. }
  49091. /**
  49092. * Glow layer options. This helps customizing the behaviour
  49093. * of the glow layer.
  49094. */
  49095. export interface IGlowLayerOptions {
  49096. /**
  49097. * Multiplication factor apply to the canvas size to compute the render target size
  49098. * used to generated the glowing objects (the smaller the faster).
  49099. */
  49100. mainTextureRatio: number;
  49101. /**
  49102. * Enforces a fixed size texture to ensure resize independant blur.
  49103. */
  49104. mainTextureFixedSize?: number;
  49105. /**
  49106. * How big is the kernel of the blur texture.
  49107. */
  49108. blurKernelSize: number;
  49109. /**
  49110. * The camera attached to the layer.
  49111. */
  49112. camera: Nullable<Camera>;
  49113. /**
  49114. * Enable MSAA by chosing the number of samples.
  49115. */
  49116. mainTextureSamples?: number;
  49117. /**
  49118. * The rendering group to draw the layer in.
  49119. */
  49120. renderingGroupId: number;
  49121. }
  49122. /**
  49123. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49124. *
  49125. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49126. * glowy meshes to your scene.
  49127. *
  49128. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49129. */
  49130. export class GlowLayer extends EffectLayer {
  49131. /**
  49132. * Effect Name of the layer.
  49133. */
  49134. static readonly EffectName: string;
  49135. /**
  49136. * The default blur kernel size used for the glow.
  49137. */
  49138. static DefaultBlurKernelSize: number;
  49139. /**
  49140. * The default texture size ratio used for the glow.
  49141. */
  49142. static DefaultTextureRatio: number;
  49143. /**
  49144. * Sets the kernel size of the blur.
  49145. */
  49146. /**
  49147. * Gets the kernel size of the blur.
  49148. */
  49149. blurKernelSize: number;
  49150. /**
  49151. * Sets the glow intensity.
  49152. */
  49153. /**
  49154. * Gets the glow intensity.
  49155. */
  49156. intensity: number;
  49157. private _options;
  49158. private _intensity;
  49159. private _horizontalBlurPostprocess1;
  49160. private _verticalBlurPostprocess1;
  49161. private _horizontalBlurPostprocess2;
  49162. private _verticalBlurPostprocess2;
  49163. private _blurTexture1;
  49164. private _blurTexture2;
  49165. private _postProcesses1;
  49166. private _postProcesses2;
  49167. private _includedOnlyMeshes;
  49168. private _excludedMeshes;
  49169. /**
  49170. * Callback used to let the user override the color selection on a per mesh basis
  49171. */
  49172. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49173. /**
  49174. * Callback used to let the user override the texture selection on a per mesh basis
  49175. */
  49176. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49177. /**
  49178. * Instantiates a new glow Layer and references it to the scene.
  49179. * @param name The name of the layer
  49180. * @param scene The scene to use the layer in
  49181. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49182. */
  49183. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49184. /**
  49185. * Get the effect name of the layer.
  49186. * @return The effect name
  49187. */
  49188. getEffectName(): string;
  49189. /**
  49190. * Create the merge effect. This is the shader use to blit the information back
  49191. * to the main canvas at the end of the scene rendering.
  49192. */
  49193. protected _createMergeEffect(): Effect;
  49194. /**
  49195. * Creates the render target textures and post processes used in the glow layer.
  49196. */
  49197. protected _createTextureAndPostProcesses(): void;
  49198. /**
  49199. * Checks for the readiness of the element composing the layer.
  49200. * @param subMesh the mesh to check for
  49201. * @param useInstances specify wether or not to use instances to render the mesh
  49202. * @param emissiveTexture the associated emissive texture used to generate the glow
  49203. * @return true if ready otherwise, false
  49204. */
  49205. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49206. /**
  49207. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49208. */
  49209. needStencil(): boolean;
  49210. /**
  49211. * Returns true if the mesh can be rendered, otherwise false.
  49212. * @param mesh The mesh to render
  49213. * @param material The material used on the mesh
  49214. * @returns true if it can be rendered otherwise false
  49215. */
  49216. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49217. /**
  49218. * Implementation specific of rendering the generating effect on the main canvas.
  49219. * @param effect The effect used to render through
  49220. */
  49221. protected _internalRender(effect: Effect): void;
  49222. /**
  49223. * Sets the required values for both the emissive texture and and the main color.
  49224. */
  49225. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49226. /**
  49227. * Returns true if the mesh should render, otherwise false.
  49228. * @param mesh The mesh to render
  49229. * @returns true if it should render otherwise false
  49230. */
  49231. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49232. /**
  49233. * Adds specific effects defines.
  49234. * @param defines The defines to add specifics to.
  49235. */
  49236. protected _addCustomEffectDefines(defines: string[]): void;
  49237. /**
  49238. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49239. * @param mesh The mesh to exclude from the glow layer
  49240. */
  49241. addExcludedMesh(mesh: Mesh): void;
  49242. /**
  49243. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49244. * @param mesh The mesh to remove
  49245. */
  49246. removeExcludedMesh(mesh: Mesh): void;
  49247. /**
  49248. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49249. * @param mesh The mesh to include in the glow layer
  49250. */
  49251. addIncludedOnlyMesh(mesh: Mesh): void;
  49252. /**
  49253. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49254. * @param mesh The mesh to remove
  49255. */
  49256. removeIncludedOnlyMesh(mesh: Mesh): void;
  49257. /**
  49258. * Determine if a given mesh will be used in the glow layer
  49259. * @param mesh The mesh to test
  49260. * @returns true if the mesh will be highlighted by the current glow layer
  49261. */
  49262. hasMesh(mesh: AbstractMesh): boolean;
  49263. /**
  49264. * Free any resources and references associated to a mesh.
  49265. * Internal use
  49266. * @param mesh The mesh to free.
  49267. * @hidden
  49268. */
  49269. _disposeMesh(mesh: Mesh): void;
  49270. /**
  49271. * Gets the class name of the effect layer
  49272. * @returns the string with the class name of the effect layer
  49273. */
  49274. getClassName(): string;
  49275. /**
  49276. * Serializes this glow layer
  49277. * @returns a serialized glow layer object
  49278. */
  49279. serialize(): any;
  49280. /**
  49281. * Creates a Glow Layer from parsed glow layer data
  49282. * @param parsedGlowLayer defines glow layer data
  49283. * @param scene defines the current scene
  49284. * @param rootUrl defines the root URL containing the glow layer information
  49285. * @returns a parsed Glow Layer
  49286. */
  49287. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49288. }
  49289. }
  49290. declare module BABYLON {
  49291. /** @hidden */
  49292. export var glowBlurPostProcessPixelShader: {
  49293. name: string;
  49294. shader: string;
  49295. };
  49296. }
  49297. declare module BABYLON {
  49298. interface AbstractScene {
  49299. /**
  49300. * Return a the first highlight layer of the scene with a given name.
  49301. * @param name The name of the highlight layer to look for.
  49302. * @return The highlight layer if found otherwise null.
  49303. */
  49304. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49305. }
  49306. /**
  49307. * Highlight layer options. This helps customizing the behaviour
  49308. * of the highlight layer.
  49309. */
  49310. export interface IHighlightLayerOptions {
  49311. /**
  49312. * Multiplication factor apply to the canvas size to compute the render target size
  49313. * used to generated the glowing objects (the smaller the faster).
  49314. */
  49315. mainTextureRatio: number;
  49316. /**
  49317. * Enforces a fixed size texture to ensure resize independant blur.
  49318. */
  49319. mainTextureFixedSize?: number;
  49320. /**
  49321. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49322. * of the picture to blur (the smaller the faster).
  49323. */
  49324. blurTextureSizeRatio: number;
  49325. /**
  49326. * How big in texel of the blur texture is the vertical blur.
  49327. */
  49328. blurVerticalSize: number;
  49329. /**
  49330. * How big in texel of the blur texture is the horizontal blur.
  49331. */
  49332. blurHorizontalSize: number;
  49333. /**
  49334. * Alpha blending mode used to apply the blur. Default is combine.
  49335. */
  49336. alphaBlendingMode: number;
  49337. /**
  49338. * The camera attached to the layer.
  49339. */
  49340. camera: Nullable<Camera>;
  49341. /**
  49342. * Should we display highlight as a solid stroke?
  49343. */
  49344. isStroke?: boolean;
  49345. /**
  49346. * The rendering group to draw the layer in.
  49347. */
  49348. renderingGroupId: number;
  49349. }
  49350. /**
  49351. * The highlight layer Helps adding a glow effect around a mesh.
  49352. *
  49353. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49354. * glowy meshes to your scene.
  49355. *
  49356. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49357. */
  49358. export class HighlightLayer extends EffectLayer {
  49359. name: string;
  49360. /**
  49361. * Effect Name of the highlight layer.
  49362. */
  49363. static readonly EffectName: string;
  49364. /**
  49365. * The neutral color used during the preparation of the glow effect.
  49366. * This is black by default as the blend operation is a blend operation.
  49367. */
  49368. static NeutralColor: Color4;
  49369. /**
  49370. * Stencil value used for glowing meshes.
  49371. */
  49372. static GlowingMeshStencilReference: number;
  49373. /**
  49374. * Stencil value used for the other meshes in the scene.
  49375. */
  49376. static NormalMeshStencilReference: number;
  49377. /**
  49378. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49379. */
  49380. innerGlow: boolean;
  49381. /**
  49382. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49383. */
  49384. outerGlow: boolean;
  49385. /**
  49386. * Specifies the horizontal size of the blur.
  49387. */
  49388. /**
  49389. * Gets the horizontal size of the blur.
  49390. */
  49391. blurHorizontalSize: number;
  49392. /**
  49393. * Specifies the vertical size of the blur.
  49394. */
  49395. /**
  49396. * Gets the vertical size of the blur.
  49397. */
  49398. blurVerticalSize: number;
  49399. /**
  49400. * An event triggered when the highlight layer is being blurred.
  49401. */
  49402. onBeforeBlurObservable: Observable<HighlightLayer>;
  49403. /**
  49404. * An event triggered when the highlight layer has been blurred.
  49405. */
  49406. onAfterBlurObservable: Observable<HighlightLayer>;
  49407. private _instanceGlowingMeshStencilReference;
  49408. private _options;
  49409. private _downSamplePostprocess;
  49410. private _horizontalBlurPostprocess;
  49411. private _verticalBlurPostprocess;
  49412. private _blurTexture;
  49413. private _meshes;
  49414. private _excludedMeshes;
  49415. /**
  49416. * Instantiates a new highlight Layer and references it to the scene..
  49417. * @param name The name of the layer
  49418. * @param scene The scene to use the layer in
  49419. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49420. */
  49421. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49422. /**
  49423. * Get the effect name of the layer.
  49424. * @return The effect name
  49425. */
  49426. getEffectName(): string;
  49427. /**
  49428. * Create the merge effect. This is the shader use to blit the information back
  49429. * to the main canvas at the end of the scene rendering.
  49430. */
  49431. protected _createMergeEffect(): Effect;
  49432. /**
  49433. * Creates the render target textures and post processes used in the highlight layer.
  49434. */
  49435. protected _createTextureAndPostProcesses(): void;
  49436. /**
  49437. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49438. */
  49439. needStencil(): boolean;
  49440. /**
  49441. * Checks for the readiness of the element composing the layer.
  49442. * @param subMesh the mesh to check for
  49443. * @param useInstances specify wether or not to use instances to render the mesh
  49444. * @param emissiveTexture the associated emissive texture used to generate the glow
  49445. * @return true if ready otherwise, false
  49446. */
  49447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49448. /**
  49449. * Implementation specific of rendering the generating effect on the main canvas.
  49450. * @param effect The effect used to render through
  49451. */
  49452. protected _internalRender(effect: Effect): void;
  49453. /**
  49454. * Returns true if the layer contains information to display, otherwise false.
  49455. */
  49456. shouldRender(): boolean;
  49457. /**
  49458. * Returns true if the mesh should render, otherwise false.
  49459. * @param mesh The mesh to render
  49460. * @returns true if it should render otherwise false
  49461. */
  49462. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49463. /**
  49464. * Sets the required values for both the emissive texture and and the main color.
  49465. */
  49466. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49467. /**
  49468. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49469. * @param mesh The mesh to exclude from the highlight layer
  49470. */
  49471. addExcludedMesh(mesh: Mesh): void;
  49472. /**
  49473. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49474. * @param mesh The mesh to highlight
  49475. */
  49476. removeExcludedMesh(mesh: Mesh): void;
  49477. /**
  49478. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49479. * @param mesh mesh to test
  49480. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49481. */
  49482. hasMesh(mesh: AbstractMesh): boolean;
  49483. /**
  49484. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49485. * @param mesh The mesh to highlight
  49486. * @param color The color of the highlight
  49487. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49488. */
  49489. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49490. /**
  49491. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49492. * @param mesh The mesh to highlight
  49493. */
  49494. removeMesh(mesh: Mesh): void;
  49495. /**
  49496. * Force the stencil to the normal expected value for none glowing parts
  49497. */
  49498. private _defaultStencilReference;
  49499. /**
  49500. * Free any resources and references associated to a mesh.
  49501. * Internal use
  49502. * @param mesh The mesh to free.
  49503. * @hidden
  49504. */
  49505. _disposeMesh(mesh: Mesh): void;
  49506. /**
  49507. * Dispose the highlight layer and free resources.
  49508. */
  49509. dispose(): void;
  49510. /**
  49511. * Gets the class name of the effect layer
  49512. * @returns the string with the class name of the effect layer
  49513. */
  49514. getClassName(): string;
  49515. /**
  49516. * Serializes this Highlight layer
  49517. * @returns a serialized Highlight layer object
  49518. */
  49519. serialize(): any;
  49520. /**
  49521. * Creates a Highlight layer from parsed Highlight layer data
  49522. * @param parsedHightlightLayer defines the Highlight layer data
  49523. * @param scene defines the current scene
  49524. * @param rootUrl defines the root URL containing the Highlight layer information
  49525. * @returns a parsed Highlight layer
  49526. */
  49527. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49528. }
  49529. }
  49530. declare module BABYLON {
  49531. interface AbstractScene {
  49532. /**
  49533. * The list of layers (background and foreground) of the scene
  49534. */
  49535. layers: Array<Layer>;
  49536. }
  49537. /**
  49538. * Defines the layer scene component responsible to manage any layers
  49539. * in a given scene.
  49540. */
  49541. export class LayerSceneComponent implements ISceneComponent {
  49542. /**
  49543. * The component name helpfull to identify the component in the list of scene components.
  49544. */
  49545. readonly name: string;
  49546. /**
  49547. * The scene the component belongs to.
  49548. */
  49549. scene: Scene;
  49550. private _engine;
  49551. /**
  49552. * Creates a new instance of the component for the given scene
  49553. * @param scene Defines the scene to register the component in
  49554. */
  49555. constructor(scene: Scene);
  49556. /**
  49557. * Registers the component in a given scene
  49558. */
  49559. register(): void;
  49560. /**
  49561. * Rebuilds the elements related to this component in case of
  49562. * context lost for instance.
  49563. */
  49564. rebuild(): void;
  49565. /**
  49566. * Disposes the component and the associated ressources.
  49567. */
  49568. dispose(): void;
  49569. private _draw;
  49570. private _drawCameraPredicate;
  49571. private _drawCameraBackground;
  49572. private _drawCameraForeground;
  49573. private _drawRenderTargetPredicate;
  49574. private _drawRenderTargetBackground;
  49575. private _drawRenderTargetForeground;
  49576. /**
  49577. * Adds all the elements from the container to the scene
  49578. * @param container the container holding the elements
  49579. */
  49580. addFromContainer(container: AbstractScene): void;
  49581. /**
  49582. * Removes all the elements in the container from the scene
  49583. * @param container contains the elements to remove
  49584. * @param dispose if the removed element should be disposed (default: false)
  49585. */
  49586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49587. }
  49588. }
  49589. declare module BABYLON {
  49590. /** @hidden */
  49591. export var layerPixelShader: {
  49592. name: string;
  49593. shader: string;
  49594. };
  49595. }
  49596. declare module BABYLON {
  49597. /** @hidden */
  49598. export var layerVertexShader: {
  49599. name: string;
  49600. shader: string;
  49601. };
  49602. }
  49603. declare module BABYLON {
  49604. /**
  49605. * This represents a full screen 2d layer.
  49606. * This can be useful to display a picture in the background of your scene for instance.
  49607. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49608. */
  49609. export class Layer {
  49610. /**
  49611. * Define the name of the layer.
  49612. */
  49613. name: string;
  49614. /**
  49615. * Define the texture the layer should display.
  49616. */
  49617. texture: Nullable<Texture>;
  49618. /**
  49619. * Is the layer in background or foreground.
  49620. */
  49621. isBackground: boolean;
  49622. /**
  49623. * Define the color of the layer (instead of texture).
  49624. */
  49625. color: Color4;
  49626. /**
  49627. * Define the scale of the layer in order to zoom in out of the texture.
  49628. */
  49629. scale: Vector2;
  49630. /**
  49631. * Define an offset for the layer in order to shift the texture.
  49632. */
  49633. offset: Vector2;
  49634. /**
  49635. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49636. */
  49637. alphaBlendingMode: number;
  49638. /**
  49639. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49640. * Alpha test will not mix with the background color in case of transparency.
  49641. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49642. */
  49643. alphaTest: boolean;
  49644. /**
  49645. * Define a mask to restrict the layer to only some of the scene cameras.
  49646. */
  49647. layerMask: number;
  49648. /**
  49649. * Define the list of render target the layer is visible into.
  49650. */
  49651. renderTargetTextures: RenderTargetTexture[];
  49652. /**
  49653. * Define if the layer is only used in renderTarget or if it also
  49654. * renders in the main frame buffer of the canvas.
  49655. */
  49656. renderOnlyInRenderTargetTextures: boolean;
  49657. private _scene;
  49658. private _vertexBuffers;
  49659. private _indexBuffer;
  49660. private _effect;
  49661. private _alphaTestEffect;
  49662. /**
  49663. * An event triggered when the layer is disposed.
  49664. */
  49665. onDisposeObservable: Observable<Layer>;
  49666. private _onDisposeObserver;
  49667. /**
  49668. * Back compatibility with callback before the onDisposeObservable existed.
  49669. * The set callback will be triggered when the layer has been disposed.
  49670. */
  49671. onDispose: () => void;
  49672. /**
  49673. * An event triggered before rendering the scene
  49674. */
  49675. onBeforeRenderObservable: Observable<Layer>;
  49676. private _onBeforeRenderObserver;
  49677. /**
  49678. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49679. * The set callback will be triggered just before rendering the layer.
  49680. */
  49681. onBeforeRender: () => void;
  49682. /**
  49683. * An event triggered after rendering the scene
  49684. */
  49685. onAfterRenderObservable: Observable<Layer>;
  49686. private _onAfterRenderObserver;
  49687. /**
  49688. * Back compatibility with callback before the onAfterRenderObservable existed.
  49689. * The set callback will be triggered just after rendering the layer.
  49690. */
  49691. onAfterRender: () => void;
  49692. /**
  49693. * Instantiates a new layer.
  49694. * This represents a full screen 2d layer.
  49695. * This can be useful to display a picture in the background of your scene for instance.
  49696. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49697. * @param name Define the name of the layer in the scene
  49698. * @param imgUrl Define the url of the texture to display in the layer
  49699. * @param scene Define the scene the layer belongs to
  49700. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49701. * @param color Defines a color for the layer
  49702. */
  49703. constructor(
  49704. /**
  49705. * Define the name of the layer.
  49706. */
  49707. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49708. private _createIndexBuffer;
  49709. /** @hidden */
  49710. _rebuild(): void;
  49711. /**
  49712. * Renders the layer in the scene.
  49713. */
  49714. render(): void;
  49715. /**
  49716. * Disposes and releases the associated ressources.
  49717. */
  49718. dispose(): void;
  49719. }
  49720. }
  49721. declare module BABYLON {
  49722. /** @hidden */
  49723. export var lensFlarePixelShader: {
  49724. name: string;
  49725. shader: string;
  49726. };
  49727. }
  49728. declare module BABYLON {
  49729. /** @hidden */
  49730. export var lensFlareVertexShader: {
  49731. name: string;
  49732. shader: string;
  49733. };
  49734. }
  49735. declare module BABYLON {
  49736. /**
  49737. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49738. * It is usually composed of several `lensFlare`.
  49739. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49740. */
  49741. export class LensFlareSystem {
  49742. /**
  49743. * Define the name of the lens flare system
  49744. */
  49745. name: string;
  49746. /**
  49747. * List of lens flares used in this system.
  49748. */
  49749. lensFlares: LensFlare[];
  49750. /**
  49751. * Define a limit from the border the lens flare can be visible.
  49752. */
  49753. borderLimit: number;
  49754. /**
  49755. * Define a viewport border we do not want to see the lens flare in.
  49756. */
  49757. viewportBorder: number;
  49758. /**
  49759. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49760. */
  49761. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49762. /**
  49763. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49764. */
  49765. layerMask: number;
  49766. /**
  49767. * Define the id of the lens flare system in the scene.
  49768. * (equal to name by default)
  49769. */
  49770. id: string;
  49771. private _scene;
  49772. private _emitter;
  49773. private _vertexBuffers;
  49774. private _indexBuffer;
  49775. private _effect;
  49776. private _positionX;
  49777. private _positionY;
  49778. private _isEnabled;
  49779. /** @hidden */
  49780. static _SceneComponentInitialization: (scene: Scene) => void;
  49781. /**
  49782. * Instantiates a lens flare system.
  49783. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49784. * It is usually composed of several `lensFlare`.
  49785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49786. * @param name Define the name of the lens flare system in the scene
  49787. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49788. * @param scene Define the scene the lens flare system belongs to
  49789. */
  49790. constructor(
  49791. /**
  49792. * Define the name of the lens flare system
  49793. */
  49794. name: string, emitter: any, scene: Scene);
  49795. /**
  49796. * Define if the lens flare system is enabled.
  49797. */
  49798. isEnabled: boolean;
  49799. /**
  49800. * Get the scene the effects belongs to.
  49801. * @returns the scene holding the lens flare system
  49802. */
  49803. getScene(): Scene;
  49804. /**
  49805. * Get the emitter of the lens flare system.
  49806. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49807. * @returns the emitter of the lens flare system
  49808. */
  49809. getEmitter(): any;
  49810. /**
  49811. * Set the emitter of the lens flare system.
  49812. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49813. * @param newEmitter Define the new emitter of the system
  49814. */
  49815. setEmitter(newEmitter: any): void;
  49816. /**
  49817. * Get the lens flare system emitter position.
  49818. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49819. * @returns the position
  49820. */
  49821. getEmitterPosition(): Vector3;
  49822. /**
  49823. * @hidden
  49824. */
  49825. computeEffectivePosition(globalViewport: Viewport): boolean;
  49826. /** @hidden */
  49827. _isVisible(): boolean;
  49828. /**
  49829. * @hidden
  49830. */
  49831. render(): boolean;
  49832. /**
  49833. * Dispose and release the lens flare with its associated resources.
  49834. */
  49835. dispose(): void;
  49836. /**
  49837. * Parse a lens flare system from a JSON repressentation
  49838. * @param parsedLensFlareSystem Define the JSON to parse
  49839. * @param scene Define the scene the parsed system should be instantiated in
  49840. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49841. * @returns the parsed system
  49842. */
  49843. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49844. /**
  49845. * Serialize the current Lens Flare System into a JSON representation.
  49846. * @returns the serialized JSON
  49847. */
  49848. serialize(): any;
  49849. }
  49850. }
  49851. declare module BABYLON {
  49852. /**
  49853. * This represents one of the lens effect in a `lensFlareSystem`.
  49854. * It controls one of the indiviual texture used in the effect.
  49855. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49856. */
  49857. export class LensFlare {
  49858. /**
  49859. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49860. */
  49861. size: number;
  49862. /**
  49863. * 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.
  49864. */
  49865. position: number;
  49866. /**
  49867. * Define the lens color.
  49868. */
  49869. color: Color3;
  49870. /**
  49871. * Define the lens texture.
  49872. */
  49873. texture: Nullable<Texture>;
  49874. /**
  49875. * Define the alpha mode to render this particular lens.
  49876. */
  49877. alphaMode: number;
  49878. private _system;
  49879. /**
  49880. * Creates a new Lens Flare.
  49881. * This represents one of the lens effect in a `lensFlareSystem`.
  49882. * It controls one of the indiviual texture used in the effect.
  49883. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49884. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49885. * @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.
  49886. * @param color Define the lens color
  49887. * @param imgUrl Define the lens texture url
  49888. * @param system Define the `lensFlareSystem` this flare is part of
  49889. * @returns The newly created Lens Flare
  49890. */
  49891. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49892. /**
  49893. * Instantiates a new Lens Flare.
  49894. * This represents one of the lens effect in a `lensFlareSystem`.
  49895. * It controls one of the indiviual texture used in the effect.
  49896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49897. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49898. * @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.
  49899. * @param color Define the lens color
  49900. * @param imgUrl Define the lens texture url
  49901. * @param system Define the `lensFlareSystem` this flare is part of
  49902. */
  49903. constructor(
  49904. /**
  49905. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49906. */
  49907. size: number,
  49908. /**
  49909. * 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.
  49910. */
  49911. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49912. /**
  49913. * Dispose and release the lens flare with its associated resources.
  49914. */
  49915. dispose(): void;
  49916. }
  49917. }
  49918. declare module BABYLON {
  49919. interface AbstractScene {
  49920. /**
  49921. * The list of lens flare system added to the scene
  49922. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49923. */
  49924. lensFlareSystems: Array<LensFlareSystem>;
  49925. /**
  49926. * Removes the given lens flare system from this scene.
  49927. * @param toRemove The lens flare system to remove
  49928. * @returns The index of the removed lens flare system
  49929. */
  49930. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49931. /**
  49932. * Adds the given lens flare system to this scene
  49933. * @param newLensFlareSystem The lens flare system to add
  49934. */
  49935. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49936. /**
  49937. * Gets a lens flare system using its name
  49938. * @param name defines the name to look for
  49939. * @returns the lens flare system or null if not found
  49940. */
  49941. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49942. /**
  49943. * Gets a lens flare system using its id
  49944. * @param id defines the id to look for
  49945. * @returns the lens flare system or null if not found
  49946. */
  49947. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49948. }
  49949. /**
  49950. * Defines the lens flare scene component responsible to manage any lens flares
  49951. * in a given scene.
  49952. */
  49953. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49954. /**
  49955. * The component name helpfull to identify the component in the list of scene components.
  49956. */
  49957. readonly name: string;
  49958. /**
  49959. * The scene the component belongs to.
  49960. */
  49961. scene: Scene;
  49962. /**
  49963. * Creates a new instance of the component for the given scene
  49964. * @param scene Defines the scene to register the component in
  49965. */
  49966. constructor(scene: Scene);
  49967. /**
  49968. * Registers the component in a given scene
  49969. */
  49970. register(): void;
  49971. /**
  49972. * Rebuilds the elements related to this component in case of
  49973. * context lost for instance.
  49974. */
  49975. rebuild(): void;
  49976. /**
  49977. * Adds all the elements from the container to the scene
  49978. * @param container the container holding the elements
  49979. */
  49980. addFromContainer(container: AbstractScene): void;
  49981. /**
  49982. * Removes all the elements in the container from the scene
  49983. * @param container contains the elements to remove
  49984. * @param dispose if the removed element should be disposed (default: false)
  49985. */
  49986. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49987. /**
  49988. * Serializes the component data to the specified json object
  49989. * @param serializationObject The object to serialize to
  49990. */
  49991. serialize(serializationObject: any): void;
  49992. /**
  49993. * Disposes the component and the associated ressources.
  49994. */
  49995. dispose(): void;
  49996. private _draw;
  49997. }
  49998. }
  49999. declare module BABYLON {
  50000. /**
  50001. * Defines the shadow generator component responsible to manage any shadow generators
  50002. * in a given scene.
  50003. */
  50004. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50005. /**
  50006. * The component name helpfull to identify the component in the list of scene components.
  50007. */
  50008. readonly name: string;
  50009. /**
  50010. * The scene the component belongs to.
  50011. */
  50012. scene: Scene;
  50013. /**
  50014. * Creates a new instance of the component for the given scene
  50015. * @param scene Defines the scene to register the component in
  50016. */
  50017. constructor(scene: Scene);
  50018. /**
  50019. * Registers the component in a given scene
  50020. */
  50021. register(): void;
  50022. /**
  50023. * Rebuilds the elements related to this component in case of
  50024. * context lost for instance.
  50025. */
  50026. rebuild(): void;
  50027. /**
  50028. * Serializes the component data to the specified json object
  50029. * @param serializationObject The object to serialize to
  50030. */
  50031. serialize(serializationObject: any): void;
  50032. /**
  50033. * Adds all the elements from the container to the scene
  50034. * @param container the container holding the elements
  50035. */
  50036. addFromContainer(container: AbstractScene): void;
  50037. /**
  50038. * Removes all the elements in the container from the scene
  50039. * @param container contains the elements to remove
  50040. * @param dispose if the removed element should be disposed (default: false)
  50041. */
  50042. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50043. /**
  50044. * Rebuilds the elements related to this component in case of
  50045. * context lost for instance.
  50046. */
  50047. dispose(): void;
  50048. private _gatherRenderTargets;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * A point light is a light defined by an unique point in world space.
  50054. * The light is emitted in every direction from this point.
  50055. * A good example of a point light is a standard light bulb.
  50056. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50057. */
  50058. export class PointLight extends ShadowLight {
  50059. private _shadowAngle;
  50060. /**
  50061. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50062. * This specifies what angle the shadow will use to be created.
  50063. *
  50064. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50065. */
  50066. /**
  50067. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50068. * This specifies what angle the shadow will use to be created.
  50069. *
  50070. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50071. */
  50072. shadowAngle: number;
  50073. /**
  50074. * Gets the direction if it has been set.
  50075. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50076. */
  50077. /**
  50078. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50079. */
  50080. direction: Vector3;
  50081. /**
  50082. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50083. * A PointLight emits the light in every direction.
  50084. * It can cast shadows.
  50085. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50086. * ```javascript
  50087. * var pointLight = new PointLight("pl", camera.position, scene);
  50088. * ```
  50089. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50090. * @param name The light friendly name
  50091. * @param position The position of the point light in the scene
  50092. * @param scene The scene the lights belongs to
  50093. */
  50094. constructor(name: string, position: Vector3, scene: Scene);
  50095. /**
  50096. * Returns the string "PointLight"
  50097. * @returns the class name
  50098. */
  50099. getClassName(): string;
  50100. /**
  50101. * Returns the integer 0.
  50102. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50103. */
  50104. getTypeID(): number;
  50105. /**
  50106. * Specifies wether or not the shadowmap should be a cube texture.
  50107. * @returns true if the shadowmap needs to be a cube texture.
  50108. */
  50109. needCube(): boolean;
  50110. /**
  50111. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50112. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50113. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50114. */
  50115. getShadowDirection(faceIndex?: number): Vector3;
  50116. /**
  50117. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50118. * - fov = PI / 2
  50119. * - aspect ratio : 1.0
  50120. * - z-near and far equal to the active camera minZ and maxZ.
  50121. * Returns the PointLight.
  50122. */
  50123. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50124. protected _buildUniformLayout(): void;
  50125. /**
  50126. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50127. * @param effect The effect to update
  50128. * @param lightIndex The index of the light in the effect to update
  50129. * @returns The point light
  50130. */
  50131. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50132. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50133. /**
  50134. * Prepares the list of defines specific to the light type.
  50135. * @param defines the list of defines
  50136. * @param lightIndex defines the index of the light for the effect
  50137. */
  50138. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50139. }
  50140. }
  50141. declare module BABYLON {
  50142. /**
  50143. * Header information of HDR texture files.
  50144. */
  50145. export interface HDRInfo {
  50146. /**
  50147. * The height of the texture in pixels.
  50148. */
  50149. height: number;
  50150. /**
  50151. * The width of the texture in pixels.
  50152. */
  50153. width: number;
  50154. /**
  50155. * The index of the beginning of the data in the binary file.
  50156. */
  50157. dataPosition: number;
  50158. }
  50159. /**
  50160. * This groups tools to convert HDR texture to native colors array.
  50161. */
  50162. export class HDRTools {
  50163. private static Ldexp;
  50164. private static Rgbe2float;
  50165. private static readStringLine;
  50166. /**
  50167. * Reads header information from an RGBE texture stored in a native array.
  50168. * More information on this format are available here:
  50169. * https://en.wikipedia.org/wiki/RGBE_image_format
  50170. *
  50171. * @param uint8array The binary file stored in native array.
  50172. * @return The header information.
  50173. */
  50174. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50175. /**
  50176. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50177. * This RGBE texture needs to store the information as a panorama.
  50178. *
  50179. * More information on this format are available here:
  50180. * https://en.wikipedia.org/wiki/RGBE_image_format
  50181. *
  50182. * @param buffer The binary file stored in an array buffer.
  50183. * @param size The expected size of the extracted cubemap.
  50184. * @return The Cube Map information.
  50185. */
  50186. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50187. /**
  50188. * Returns the pixels data extracted from an RGBE texture.
  50189. * This pixels will be stored left to right up to down in the R G B order in one array.
  50190. *
  50191. * More information on this format are available here:
  50192. * https://en.wikipedia.org/wiki/RGBE_image_format
  50193. *
  50194. * @param uint8array The binary file stored in an array buffer.
  50195. * @param hdrInfo The header information of the file.
  50196. * @return The pixels data in RGB right to left up to down order.
  50197. */
  50198. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50199. private static RGBE_ReadPixels_RLE;
  50200. }
  50201. }
  50202. declare module BABYLON {
  50203. /**
  50204. * This represents a texture coming from an HDR input.
  50205. *
  50206. * The only supported format is currently panorama picture stored in RGBE format.
  50207. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50208. */
  50209. export class HDRCubeTexture extends BaseTexture {
  50210. private static _facesMapping;
  50211. private _generateHarmonics;
  50212. private _noMipmap;
  50213. private _textureMatrix;
  50214. private _size;
  50215. private _onLoad;
  50216. private _onError;
  50217. /**
  50218. * The texture URL.
  50219. */
  50220. url: string;
  50221. /**
  50222. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50223. */
  50224. coordinatesMode: number;
  50225. protected _isBlocking: boolean;
  50226. /**
  50227. * Sets wether or not the texture is blocking during loading.
  50228. */
  50229. /**
  50230. * Gets wether or not the texture is blocking during loading.
  50231. */
  50232. isBlocking: boolean;
  50233. protected _rotationY: number;
  50234. /**
  50235. * Sets texture matrix rotation angle around Y axis in radians.
  50236. */
  50237. /**
  50238. * Gets texture matrix rotation angle around Y axis radians.
  50239. */
  50240. rotationY: number;
  50241. /**
  50242. * Gets or sets the center of the bounding box associated with the cube texture
  50243. * It must define where the camera used to render the texture was set
  50244. */
  50245. boundingBoxPosition: Vector3;
  50246. private _boundingBoxSize;
  50247. /**
  50248. * Gets or sets the size of the bounding box associated with the cube texture
  50249. * When defined, the cubemap will switch to local mode
  50250. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50251. * @example https://www.babylonjs-playground.com/#RNASML
  50252. */
  50253. boundingBoxSize: Vector3;
  50254. /**
  50255. * Instantiates an HDRTexture from the following parameters.
  50256. *
  50257. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50258. * @param scene The scene the texture will be used in
  50259. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50260. * @param noMipmap Forces to not generate the mipmap if true
  50261. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50262. * @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)
  50263. * @param reserved Reserved flag for internal use.
  50264. */
  50265. 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>);
  50266. /**
  50267. * Get the current class name of the texture useful for serialization or dynamic coding.
  50268. * @returns "HDRCubeTexture"
  50269. */
  50270. getClassName(): string;
  50271. /**
  50272. * Occurs when the file is raw .hdr file.
  50273. */
  50274. private loadTexture;
  50275. clone(): HDRCubeTexture;
  50276. delayLoad(): void;
  50277. /**
  50278. * Get the texture reflection matrix used to rotate/transform the reflection.
  50279. * @returns the reflection matrix
  50280. */
  50281. getReflectionTextureMatrix(): Matrix;
  50282. /**
  50283. * Set the texture reflection matrix used to rotate/transform the reflection.
  50284. * @param value Define the reflection matrix to set
  50285. */
  50286. setReflectionTextureMatrix(value: Matrix): void;
  50287. /**
  50288. * Parses a JSON representation of an HDR Texture in order to create the texture
  50289. * @param parsedTexture Define the JSON representation
  50290. * @param scene Define the scene the texture should be created in
  50291. * @param rootUrl Define the root url in case we need to load relative dependencies
  50292. * @returns the newly created texture after parsing
  50293. */
  50294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50295. serialize(): any;
  50296. }
  50297. }
  50298. declare module BABYLON {
  50299. /**
  50300. * Class used to control physics engine
  50301. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50302. */
  50303. export class PhysicsEngine implements IPhysicsEngine {
  50304. private _physicsPlugin;
  50305. /**
  50306. * Global value used to control the smallest number supported by the simulation
  50307. */
  50308. static Epsilon: number;
  50309. private _impostors;
  50310. private _joints;
  50311. /**
  50312. * Gets the gravity vector used by the simulation
  50313. */
  50314. gravity: Vector3;
  50315. /**
  50316. * Factory used to create the default physics plugin.
  50317. * @returns The default physics plugin
  50318. */
  50319. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50320. /**
  50321. * Creates a new Physics Engine
  50322. * @param gravity defines the gravity vector used by the simulation
  50323. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50324. */
  50325. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50326. /**
  50327. * Sets the gravity vector used by the simulation
  50328. * @param gravity defines the gravity vector to use
  50329. */
  50330. setGravity(gravity: Vector3): void;
  50331. /**
  50332. * Set the time step of the physics engine.
  50333. * Default is 1/60.
  50334. * To slow it down, enter 1/600 for example.
  50335. * To speed it up, 1/30
  50336. * @param newTimeStep defines the new timestep to apply to this world.
  50337. */
  50338. setTimeStep(newTimeStep?: number): void;
  50339. /**
  50340. * Get the time step of the physics engine.
  50341. * @returns the current time step
  50342. */
  50343. getTimeStep(): number;
  50344. /**
  50345. * Release all resources
  50346. */
  50347. dispose(): void;
  50348. /**
  50349. * Gets the name of the current physics plugin
  50350. * @returns the name of the plugin
  50351. */
  50352. getPhysicsPluginName(): string;
  50353. /**
  50354. * Adding a new impostor for the impostor tracking.
  50355. * This will be done by the impostor itself.
  50356. * @param impostor the impostor to add
  50357. */
  50358. addImpostor(impostor: PhysicsImpostor): void;
  50359. /**
  50360. * Remove an impostor from the engine.
  50361. * This impostor and its mesh will not longer be updated by the physics engine.
  50362. * @param impostor the impostor to remove
  50363. */
  50364. removeImpostor(impostor: PhysicsImpostor): void;
  50365. /**
  50366. * Add a joint to the physics engine
  50367. * @param mainImpostor defines the main impostor to which the joint is added.
  50368. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50369. * @param joint defines the joint that will connect both impostors.
  50370. */
  50371. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50372. /**
  50373. * Removes a joint from the simulation
  50374. * @param mainImpostor defines the impostor used with the joint
  50375. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50376. * @param joint defines the joint to remove
  50377. */
  50378. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50379. /**
  50380. * Called by the scene. No need to call it.
  50381. * @param delta defines the timespam between frames
  50382. */
  50383. _step(delta: number): void;
  50384. /**
  50385. * Gets the current plugin used to run the simulation
  50386. * @returns current plugin
  50387. */
  50388. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50389. /**
  50390. * Gets the list of physic impostors
  50391. * @returns an array of PhysicsImpostor
  50392. */
  50393. getImpostors(): Array<PhysicsImpostor>;
  50394. /**
  50395. * Gets the impostor for a physics enabled object
  50396. * @param object defines the object impersonated by the impostor
  50397. * @returns the PhysicsImpostor or null if not found
  50398. */
  50399. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50400. /**
  50401. * Gets the impostor for a physics body object
  50402. * @param body defines physics body used by the impostor
  50403. * @returns the PhysicsImpostor or null if not found
  50404. */
  50405. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50406. /**
  50407. * Does a raycast in the physics world
  50408. * @param from when should the ray start?
  50409. * @param to when should the ray end?
  50410. * @returns PhysicsRaycastResult
  50411. */
  50412. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50413. }
  50414. }
  50415. declare module BABYLON {
  50416. /** @hidden */
  50417. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50418. private _useDeltaForWorldStep;
  50419. world: any;
  50420. name: string;
  50421. private _physicsMaterials;
  50422. private _fixedTimeStep;
  50423. private _cannonRaycastResult;
  50424. private _raycastResult;
  50425. private _physicsBodysToRemoveAfterStep;
  50426. BJSCANNON: any;
  50427. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50428. setGravity(gravity: Vector3): void;
  50429. setTimeStep(timeStep: number): void;
  50430. getTimeStep(): number;
  50431. executeStep(delta: number): void;
  50432. private _removeMarkedPhysicsBodiesFromWorld;
  50433. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50434. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50435. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50436. private _processChildMeshes;
  50437. removePhysicsBody(impostor: PhysicsImpostor): void;
  50438. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50439. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50440. private _addMaterial;
  50441. private _checkWithEpsilon;
  50442. private _createShape;
  50443. private _createHeightmap;
  50444. private _minus90X;
  50445. private _plus90X;
  50446. private _tmpPosition;
  50447. private _tmpDeltaPosition;
  50448. private _tmpUnityRotation;
  50449. private _updatePhysicsBodyTransformation;
  50450. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50451. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50452. isSupported(): boolean;
  50453. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50454. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50455. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50456. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50457. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50458. getBodyMass(impostor: PhysicsImpostor): number;
  50459. getBodyFriction(impostor: PhysicsImpostor): number;
  50460. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50461. getBodyRestitution(impostor: PhysicsImpostor): number;
  50462. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50463. sleepBody(impostor: PhysicsImpostor): void;
  50464. wakeUpBody(impostor: PhysicsImpostor): void;
  50465. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50466. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50468. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50469. getRadius(impostor: PhysicsImpostor): number;
  50470. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50471. dispose(): void;
  50472. private _extendNamespace;
  50473. /**
  50474. * Does a raycast in the physics world
  50475. * @param from when should the ray start?
  50476. * @param to when should the ray end?
  50477. * @returns PhysicsRaycastResult
  50478. */
  50479. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50480. }
  50481. }
  50482. declare module BABYLON {
  50483. /** @hidden */
  50484. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50485. world: any;
  50486. name: string;
  50487. BJSOIMO: any;
  50488. private _raycastResult;
  50489. constructor(iterations?: number, oimoInjection?: any);
  50490. setGravity(gravity: Vector3): void;
  50491. setTimeStep(timeStep: number): void;
  50492. getTimeStep(): number;
  50493. private _tmpImpostorsArray;
  50494. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50495. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50496. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50497. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50498. private _tmpPositionVector;
  50499. removePhysicsBody(impostor: PhysicsImpostor): void;
  50500. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50501. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50502. isSupported(): boolean;
  50503. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50504. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50505. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50506. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50507. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50508. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50509. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50510. getBodyMass(impostor: PhysicsImpostor): number;
  50511. getBodyFriction(impostor: PhysicsImpostor): number;
  50512. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50513. getBodyRestitution(impostor: PhysicsImpostor): number;
  50514. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50515. sleepBody(impostor: PhysicsImpostor): void;
  50516. wakeUpBody(impostor: PhysicsImpostor): void;
  50517. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50518. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50519. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50520. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50521. getRadius(impostor: PhysicsImpostor): number;
  50522. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50523. dispose(): void;
  50524. /**
  50525. * Does a raycast in the physics world
  50526. * @param from when should the ray start?
  50527. * @param to when should the ray end?
  50528. * @returns PhysicsRaycastResult
  50529. */
  50530. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50531. }
  50532. }
  50533. declare module BABYLON {
  50534. /**
  50535. * Class containing static functions to help procedurally build meshes
  50536. */
  50537. export class RibbonBuilder {
  50538. /**
  50539. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50540. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50541. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50542. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50543. * * 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
  50544. * * 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
  50545. * * 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
  50546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50547. * * 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
  50548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50549. * * 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
  50550. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50551. * * 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
  50552. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50554. * @param name defines the name of the mesh
  50555. * @param options defines the options used to create the mesh
  50556. * @param scene defines the hosting scene
  50557. * @returns the ribbon mesh
  50558. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50560. */
  50561. static CreateRibbon(name: string, options: {
  50562. pathArray: Vector3[][];
  50563. closeArray?: boolean;
  50564. closePath?: boolean;
  50565. offset?: number;
  50566. updatable?: boolean;
  50567. sideOrientation?: number;
  50568. frontUVs?: Vector4;
  50569. backUVs?: Vector4;
  50570. instance?: Mesh;
  50571. invertUV?: boolean;
  50572. uvs?: Vector2[];
  50573. colors?: Color4[];
  50574. }, scene?: Nullable<Scene>): Mesh;
  50575. }
  50576. }
  50577. declare module BABYLON {
  50578. /**
  50579. * Class containing static functions to help procedurally build meshes
  50580. */
  50581. export class ShapeBuilder {
  50582. /**
  50583. * 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.
  50584. * * 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.
  50585. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50586. * * 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.
  50587. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50588. * * 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
  50589. * * 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
  50590. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50592. * * 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
  50593. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50595. * @param name defines the name of the mesh
  50596. * @param options defines the options used to create the mesh
  50597. * @param scene defines the hosting scene
  50598. * @returns the extruded shape mesh
  50599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50601. */
  50602. static ExtrudeShape(name: string, options: {
  50603. shape: Vector3[];
  50604. path: Vector3[];
  50605. scale?: number;
  50606. rotation?: number;
  50607. cap?: number;
  50608. updatable?: boolean;
  50609. sideOrientation?: number;
  50610. frontUVs?: Vector4;
  50611. backUVs?: Vector4;
  50612. instance?: Mesh;
  50613. invertUV?: boolean;
  50614. }, scene?: Nullable<Scene>): Mesh;
  50615. /**
  50616. * Creates an custom extruded shape mesh.
  50617. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50618. * * 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.
  50619. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50620. * * 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
  50621. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50622. * * 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
  50623. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50624. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50625. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50626. * * 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
  50627. * * 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
  50628. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50630. * * 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
  50631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50633. * @param name defines the name of the mesh
  50634. * @param options defines the options used to create the mesh
  50635. * @param scene defines the hosting scene
  50636. * @returns the custom extruded shape mesh
  50637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50638. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50640. */
  50641. static ExtrudeShapeCustom(name: string, options: {
  50642. shape: Vector3[];
  50643. path: Vector3[];
  50644. scaleFunction?: any;
  50645. rotationFunction?: any;
  50646. ribbonCloseArray?: boolean;
  50647. ribbonClosePath?: boolean;
  50648. cap?: number;
  50649. updatable?: boolean;
  50650. sideOrientation?: number;
  50651. frontUVs?: Vector4;
  50652. backUVs?: Vector4;
  50653. instance?: Mesh;
  50654. invertUV?: boolean;
  50655. }, scene?: Nullable<Scene>): Mesh;
  50656. private static _ExtrudeShapeGeneric;
  50657. }
  50658. }
  50659. declare module BABYLON {
  50660. /**
  50661. * AmmoJS Physics plugin
  50662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50663. * @see https://github.com/kripken/ammo.js/
  50664. */
  50665. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50666. private _useDeltaForWorldStep;
  50667. /**
  50668. * Reference to the Ammo library
  50669. */
  50670. bjsAMMO: any;
  50671. /**
  50672. * Created ammoJS world which physics bodies are added to
  50673. */
  50674. world: any;
  50675. /**
  50676. * Name of the plugin
  50677. */
  50678. name: string;
  50679. private _timeStep;
  50680. private _fixedTimeStep;
  50681. private _maxSteps;
  50682. private _tmpQuaternion;
  50683. private _tmpAmmoTransform;
  50684. private _tmpAmmoQuaternion;
  50685. private _tmpAmmoConcreteContactResultCallback;
  50686. private _collisionConfiguration;
  50687. private _dispatcher;
  50688. private _overlappingPairCache;
  50689. private _solver;
  50690. private _softBodySolver;
  50691. private _tmpAmmoVectorA;
  50692. private _tmpAmmoVectorB;
  50693. private _tmpAmmoVectorC;
  50694. private _tmpAmmoVectorD;
  50695. private _tmpContactCallbackResult;
  50696. private _tmpAmmoVectorRCA;
  50697. private _tmpAmmoVectorRCB;
  50698. private _raycastResult;
  50699. private static readonly DISABLE_COLLISION_FLAG;
  50700. private static readonly KINEMATIC_FLAG;
  50701. private static readonly DISABLE_DEACTIVATION_FLAG;
  50702. /**
  50703. * Initializes the ammoJS plugin
  50704. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50705. * @param ammoInjection can be used to inject your own ammo reference
  50706. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50707. */
  50708. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50709. /**
  50710. * Sets the gravity of the physics world (m/(s^2))
  50711. * @param gravity Gravity to set
  50712. */
  50713. setGravity(gravity: Vector3): void;
  50714. /**
  50715. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50716. * @param timeStep timestep to use in seconds
  50717. */
  50718. setTimeStep(timeStep: number): void;
  50719. /**
  50720. * 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)
  50721. * @param fixedTimeStep fixedTimeStep to use in seconds
  50722. */
  50723. setFixedTimeStep(fixedTimeStep: number): void;
  50724. /**
  50725. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50726. * @param maxSteps the maximum number of steps by the physics engine per frame
  50727. */
  50728. setMaxSteps(maxSteps: number): void;
  50729. /**
  50730. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50731. * @returns the current timestep in seconds
  50732. */
  50733. getTimeStep(): number;
  50734. private _isImpostorInContact;
  50735. private _isImpostorPairInContact;
  50736. private _stepSimulation;
  50737. /**
  50738. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50739. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50740. * After the step the babylon meshes are set to the position of the physics imposters
  50741. * @param delta amount of time to step forward
  50742. * @param impostors array of imposters to update before/after the step
  50743. */
  50744. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50745. /**
  50746. * Update babylon mesh to match physics world object
  50747. * @param impostor imposter to match
  50748. */
  50749. private _afterSoftStep;
  50750. /**
  50751. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50752. * @param impostor imposter to match
  50753. */
  50754. private _ropeStep;
  50755. /**
  50756. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50757. * @param impostor imposter to match
  50758. */
  50759. private _softbodyOrClothStep;
  50760. private _tmpVector;
  50761. private _tmpMatrix;
  50762. /**
  50763. * Applies an impulse on the imposter
  50764. * @param impostor imposter to apply impulse to
  50765. * @param force amount of force to be applied to the imposter
  50766. * @param contactPoint the location to apply the impulse on the imposter
  50767. */
  50768. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50769. /**
  50770. * Applies a force on the imposter
  50771. * @param impostor imposter to apply force
  50772. * @param force amount of force to be applied to the imposter
  50773. * @param contactPoint the location to apply the force on the imposter
  50774. */
  50775. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50776. /**
  50777. * Creates a physics body using the plugin
  50778. * @param impostor the imposter to create the physics body on
  50779. */
  50780. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50781. /**
  50782. * Removes the physics body from the imposter and disposes of the body's memory
  50783. * @param impostor imposter to remove the physics body from
  50784. */
  50785. removePhysicsBody(impostor: PhysicsImpostor): void;
  50786. /**
  50787. * Generates a joint
  50788. * @param impostorJoint the imposter joint to create the joint with
  50789. */
  50790. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50791. /**
  50792. * Removes a joint
  50793. * @param impostorJoint the imposter joint to remove the joint from
  50794. */
  50795. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50796. private _addMeshVerts;
  50797. /**
  50798. * Initialise the soft body vertices to match its object's (mesh) vertices
  50799. * Softbody vertices (nodes) are in world space and to match this
  50800. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50801. * @param impostor to create the softbody for
  50802. */
  50803. private _softVertexData;
  50804. /**
  50805. * Create an impostor's soft body
  50806. * @param impostor to create the softbody for
  50807. */
  50808. private _createSoftbody;
  50809. /**
  50810. * Create cloth for an impostor
  50811. * @param impostor to create the softbody for
  50812. */
  50813. private _createCloth;
  50814. /**
  50815. * Create rope for an impostor
  50816. * @param impostor to create the softbody for
  50817. */
  50818. private _createRope;
  50819. private _addHullVerts;
  50820. private _createShape;
  50821. /**
  50822. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50823. * @param impostor imposter containing the physics body and babylon object
  50824. */
  50825. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50826. /**
  50827. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50828. * @param impostor imposter containing the physics body and babylon object
  50829. * @param newPosition new position
  50830. * @param newRotation new rotation
  50831. */
  50832. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50833. /**
  50834. * If this plugin is supported
  50835. * @returns true if its supported
  50836. */
  50837. isSupported(): boolean;
  50838. /**
  50839. * Sets the linear velocity of the physics body
  50840. * @param impostor imposter to set the velocity on
  50841. * @param velocity velocity to set
  50842. */
  50843. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50844. /**
  50845. * Sets the angular velocity of the physics body
  50846. * @param impostor imposter to set the velocity on
  50847. * @param velocity velocity to set
  50848. */
  50849. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50850. /**
  50851. * gets the linear velocity
  50852. * @param impostor imposter to get linear velocity from
  50853. * @returns linear velocity
  50854. */
  50855. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50856. /**
  50857. * gets the angular velocity
  50858. * @param impostor imposter to get angular velocity from
  50859. * @returns angular velocity
  50860. */
  50861. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50862. /**
  50863. * Sets the mass of physics body
  50864. * @param impostor imposter to set the mass on
  50865. * @param mass mass to set
  50866. */
  50867. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50868. /**
  50869. * Gets the mass of the physics body
  50870. * @param impostor imposter to get the mass from
  50871. * @returns mass
  50872. */
  50873. getBodyMass(impostor: PhysicsImpostor): number;
  50874. /**
  50875. * Gets friction of the impostor
  50876. * @param impostor impostor to get friction from
  50877. * @returns friction value
  50878. */
  50879. getBodyFriction(impostor: PhysicsImpostor): number;
  50880. /**
  50881. * Sets friction of the impostor
  50882. * @param impostor impostor to set friction on
  50883. * @param friction friction value
  50884. */
  50885. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50886. /**
  50887. * Gets restitution of the impostor
  50888. * @param impostor impostor to get restitution from
  50889. * @returns restitution value
  50890. */
  50891. getBodyRestitution(impostor: PhysicsImpostor): number;
  50892. /**
  50893. * Sets resitution of the impostor
  50894. * @param impostor impostor to set resitution on
  50895. * @param restitution resitution value
  50896. */
  50897. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50898. /**
  50899. * Gets pressure inside the impostor
  50900. * @param impostor impostor to get pressure from
  50901. * @returns pressure value
  50902. */
  50903. getBodyPressure(impostor: PhysicsImpostor): number;
  50904. /**
  50905. * Sets pressure inside a soft body impostor
  50906. * Cloth and rope must remain 0 pressure
  50907. * @param impostor impostor to set pressure on
  50908. * @param pressure pressure value
  50909. */
  50910. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50911. /**
  50912. * Gets stiffness of the impostor
  50913. * @param impostor impostor to get stiffness from
  50914. * @returns pressure value
  50915. */
  50916. getBodyStiffness(impostor: PhysicsImpostor): number;
  50917. /**
  50918. * Sets stiffness of the impostor
  50919. * @param impostor impostor to set stiffness on
  50920. * @param stiffness stiffness value from 0 to 1
  50921. */
  50922. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50923. /**
  50924. * Gets velocityIterations of the impostor
  50925. * @param impostor impostor to get velocity iterations from
  50926. * @returns velocityIterations value
  50927. */
  50928. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50929. /**
  50930. * Sets velocityIterations of the impostor
  50931. * @param impostor impostor to set velocity iterations on
  50932. * @param velocityIterations velocityIterations value
  50933. */
  50934. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50935. /**
  50936. * Gets positionIterations of the impostor
  50937. * @param impostor impostor to get position iterations from
  50938. * @returns positionIterations value
  50939. */
  50940. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50941. /**
  50942. * Sets positionIterations of the impostor
  50943. * @param impostor impostor to set position on
  50944. * @param positionIterations positionIterations value
  50945. */
  50946. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50947. /**
  50948. * Append an anchor to a cloth object
  50949. * @param impostor is the cloth impostor to add anchor to
  50950. * @param otherImpostor is the rigid impostor to anchor to
  50951. * @param width ratio across width from 0 to 1
  50952. * @param height ratio up height from 0 to 1
  50953. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50954. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50955. */
  50956. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50957. /**
  50958. * Append an hook to a rope object
  50959. * @param impostor is the rope impostor to add hook to
  50960. * @param otherImpostor is the rigid impostor to hook to
  50961. * @param length ratio along the rope from 0 to 1
  50962. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50963. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50964. */
  50965. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50966. /**
  50967. * Sleeps the physics body and stops it from being active
  50968. * @param impostor impostor to sleep
  50969. */
  50970. sleepBody(impostor: PhysicsImpostor): void;
  50971. /**
  50972. * Activates the physics body
  50973. * @param impostor impostor to activate
  50974. */
  50975. wakeUpBody(impostor: PhysicsImpostor): void;
  50976. /**
  50977. * Updates the distance parameters of the joint
  50978. * @param joint joint to update
  50979. * @param maxDistance maximum distance of the joint
  50980. * @param minDistance minimum distance of the joint
  50981. */
  50982. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50983. /**
  50984. * Sets a motor on the joint
  50985. * @param joint joint to set motor on
  50986. * @param speed speed of the motor
  50987. * @param maxForce maximum force of the motor
  50988. * @param motorIndex index of the motor
  50989. */
  50990. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50991. /**
  50992. * Sets the motors limit
  50993. * @param joint joint to set limit on
  50994. * @param upperLimit upper limit
  50995. * @param lowerLimit lower limit
  50996. */
  50997. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50998. /**
  50999. * Syncs the position and rotation of a mesh with the impostor
  51000. * @param mesh mesh to sync
  51001. * @param impostor impostor to update the mesh with
  51002. */
  51003. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51004. /**
  51005. * Gets the radius of the impostor
  51006. * @param impostor impostor to get radius from
  51007. * @returns the radius
  51008. */
  51009. getRadius(impostor: PhysicsImpostor): number;
  51010. /**
  51011. * Gets the box size of the impostor
  51012. * @param impostor impostor to get box size from
  51013. * @param result the resulting box size
  51014. */
  51015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51016. /**
  51017. * Disposes of the impostor
  51018. */
  51019. dispose(): void;
  51020. /**
  51021. * Does a raycast in the physics world
  51022. * @param from when should the ray start?
  51023. * @param to when should the ray end?
  51024. * @returns PhysicsRaycastResult
  51025. */
  51026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51027. }
  51028. }
  51029. declare module BABYLON {
  51030. interface AbstractScene {
  51031. /**
  51032. * The list of reflection probes added to the scene
  51033. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51034. */
  51035. reflectionProbes: Array<ReflectionProbe>;
  51036. /**
  51037. * Removes the given reflection probe from this scene.
  51038. * @param toRemove The reflection probe to remove
  51039. * @returns The index of the removed reflection probe
  51040. */
  51041. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51042. /**
  51043. * Adds the given reflection probe to this scene.
  51044. * @param newReflectionProbe The reflection probe to add
  51045. */
  51046. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51047. }
  51048. /**
  51049. * Class used to generate realtime reflection / refraction cube textures
  51050. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51051. */
  51052. export class ReflectionProbe {
  51053. /** defines the name of the probe */
  51054. name: string;
  51055. private _scene;
  51056. private _renderTargetTexture;
  51057. private _projectionMatrix;
  51058. private _viewMatrix;
  51059. private _target;
  51060. private _add;
  51061. private _attachedMesh;
  51062. private _invertYAxis;
  51063. /** Gets or sets probe position (center of the cube map) */
  51064. position: Vector3;
  51065. /**
  51066. * Creates a new reflection probe
  51067. * @param name defines the name of the probe
  51068. * @param size defines the texture resolution (for each face)
  51069. * @param scene defines the hosting scene
  51070. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51071. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51072. */
  51073. constructor(
  51074. /** defines the name of the probe */
  51075. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51076. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51077. samples: number;
  51078. /** Gets or sets the refresh rate to use (on every frame by default) */
  51079. refreshRate: number;
  51080. /**
  51081. * Gets the hosting scene
  51082. * @returns a Scene
  51083. */
  51084. getScene(): Scene;
  51085. /** Gets the internal CubeTexture used to render to */
  51086. readonly cubeTexture: RenderTargetTexture;
  51087. /** Gets the list of meshes to render */
  51088. readonly renderList: Nullable<AbstractMesh[]>;
  51089. /**
  51090. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51091. * @param mesh defines the mesh to attach to
  51092. */
  51093. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51094. /**
  51095. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51096. * @param renderingGroupId The rendering group id corresponding to its index
  51097. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51098. */
  51099. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51100. /**
  51101. * Clean all associated resources
  51102. */
  51103. dispose(): void;
  51104. /**
  51105. * Converts the reflection probe information to a readable string for debug purpose.
  51106. * @param fullDetails Supports for multiple levels of logging within scene loading
  51107. * @returns the human readable reflection probe info
  51108. */
  51109. toString(fullDetails?: boolean): string;
  51110. /**
  51111. * Get the class name of the relfection probe.
  51112. * @returns "ReflectionProbe"
  51113. */
  51114. getClassName(): string;
  51115. /**
  51116. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51117. * @returns The JSON representation of the texture
  51118. */
  51119. serialize(): any;
  51120. /**
  51121. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51122. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51123. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51124. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51125. * @returns The parsed reflection probe if successful
  51126. */
  51127. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51128. }
  51129. }
  51130. declare module BABYLON {
  51131. /** @hidden */
  51132. export var _BabylonLoaderRegistered: boolean;
  51133. }
  51134. declare module BABYLON {
  51135. /**
  51136. * The Physically based simple base material of BJS.
  51137. *
  51138. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51139. * It is used as the base class for both the specGloss and metalRough conventions.
  51140. */
  51141. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51142. /**
  51143. * Number of Simultaneous lights allowed on the material.
  51144. */
  51145. maxSimultaneousLights: number;
  51146. /**
  51147. * If sets to true, disables all the lights affecting the material.
  51148. */
  51149. disableLighting: boolean;
  51150. /**
  51151. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51152. */
  51153. environmentTexture: BaseTexture;
  51154. /**
  51155. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51156. */
  51157. invertNormalMapX: boolean;
  51158. /**
  51159. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51160. */
  51161. invertNormalMapY: boolean;
  51162. /**
  51163. * Normal map used in the model.
  51164. */
  51165. normalTexture: BaseTexture;
  51166. /**
  51167. * Emissivie color used to self-illuminate the model.
  51168. */
  51169. emissiveColor: Color3;
  51170. /**
  51171. * Emissivie texture used to self-illuminate the model.
  51172. */
  51173. emissiveTexture: BaseTexture;
  51174. /**
  51175. * Occlusion Channel Strenght.
  51176. */
  51177. occlusionStrength: number;
  51178. /**
  51179. * Occlusion Texture of the material (adding extra occlusion effects).
  51180. */
  51181. occlusionTexture: BaseTexture;
  51182. /**
  51183. * Defines the alpha limits in alpha test mode.
  51184. */
  51185. alphaCutOff: number;
  51186. /**
  51187. * Gets the current double sided mode.
  51188. */
  51189. /**
  51190. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51191. */
  51192. doubleSided: boolean;
  51193. /**
  51194. * Stores the pre-calculated light information of a mesh in a texture.
  51195. */
  51196. lightmapTexture: BaseTexture;
  51197. /**
  51198. * If true, the light map contains occlusion information instead of lighting info.
  51199. */
  51200. useLightmapAsShadowmap: boolean;
  51201. /**
  51202. * Instantiates a new PBRMaterial instance.
  51203. *
  51204. * @param name The material name
  51205. * @param scene The scene the material will be use in.
  51206. */
  51207. constructor(name: string, scene: Scene);
  51208. getClassName(): string;
  51209. }
  51210. }
  51211. declare module BABYLON {
  51212. /**
  51213. * The PBR material of BJS following the metal roughness convention.
  51214. *
  51215. * This fits to the PBR convention in the GLTF definition:
  51216. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51217. */
  51218. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51219. /**
  51220. * The base color has two different interpretations depending on the value of metalness.
  51221. * When the material is a metal, the base color is the specific measured reflectance value
  51222. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51223. * of the material.
  51224. */
  51225. baseColor: Color3;
  51226. /**
  51227. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51228. * well as opacity information in the alpha channel.
  51229. */
  51230. baseTexture: BaseTexture;
  51231. /**
  51232. * Specifies the metallic scalar value of the material.
  51233. * Can also be used to scale the metalness values of the metallic texture.
  51234. */
  51235. metallic: number;
  51236. /**
  51237. * Specifies the roughness scalar value of the material.
  51238. * Can also be used to scale the roughness values of the metallic texture.
  51239. */
  51240. roughness: number;
  51241. /**
  51242. * Texture containing both the metallic value in the B channel and the
  51243. * roughness value in the G channel to keep better precision.
  51244. */
  51245. metallicRoughnessTexture: BaseTexture;
  51246. /**
  51247. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51248. *
  51249. * @param name The material name
  51250. * @param scene The scene the material will be use in.
  51251. */
  51252. constructor(name: string, scene: Scene);
  51253. /**
  51254. * Return the currrent class name of the material.
  51255. */
  51256. getClassName(): string;
  51257. /**
  51258. * Makes a duplicate of the current material.
  51259. * @param name - name to use for the new material.
  51260. */
  51261. clone(name: string): PBRMetallicRoughnessMaterial;
  51262. /**
  51263. * Serialize the material to a parsable JSON object.
  51264. */
  51265. serialize(): any;
  51266. /**
  51267. * Parses a JSON object correponding to the serialize function.
  51268. */
  51269. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51270. }
  51271. }
  51272. declare module BABYLON {
  51273. /**
  51274. * The PBR material of BJS following the specular glossiness convention.
  51275. *
  51276. * This fits to the PBR convention in the GLTF definition:
  51277. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51278. */
  51279. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51280. /**
  51281. * Specifies the diffuse color of the material.
  51282. */
  51283. diffuseColor: Color3;
  51284. /**
  51285. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51286. * channel.
  51287. */
  51288. diffuseTexture: BaseTexture;
  51289. /**
  51290. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51291. */
  51292. specularColor: Color3;
  51293. /**
  51294. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51295. */
  51296. glossiness: number;
  51297. /**
  51298. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51299. */
  51300. specularGlossinessTexture: BaseTexture;
  51301. /**
  51302. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51303. *
  51304. * @param name The material name
  51305. * @param scene The scene the material will be use in.
  51306. */
  51307. constructor(name: string, scene: Scene);
  51308. /**
  51309. * Return the currrent class name of the material.
  51310. */
  51311. getClassName(): string;
  51312. /**
  51313. * Makes a duplicate of the current material.
  51314. * @param name - name to use for the new material.
  51315. */
  51316. clone(name: string): PBRSpecularGlossinessMaterial;
  51317. /**
  51318. * Serialize the material to a parsable JSON object.
  51319. */
  51320. serialize(): any;
  51321. /**
  51322. * Parses a JSON object correponding to the serialize function.
  51323. */
  51324. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51325. }
  51326. }
  51327. declare module BABYLON {
  51328. /**
  51329. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51330. * It can help converting any input color in a desired output one. This can then be used to create effects
  51331. * from sepia, black and white to sixties or futuristic rendering...
  51332. *
  51333. * The only supported format is currently 3dl.
  51334. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51335. */
  51336. export class ColorGradingTexture extends BaseTexture {
  51337. /**
  51338. * The current texture matrix. (will always be identity in color grading texture)
  51339. */
  51340. private _textureMatrix;
  51341. /**
  51342. * The texture URL.
  51343. */
  51344. url: string;
  51345. /**
  51346. * Empty line regex stored for GC.
  51347. */
  51348. private static _noneEmptyLineRegex;
  51349. private _engine;
  51350. /**
  51351. * Instantiates a ColorGradingTexture from the following parameters.
  51352. *
  51353. * @param url The location of the color gradind data (currently only supporting 3dl)
  51354. * @param scene The scene the texture will be used in
  51355. */
  51356. constructor(url: string, scene: Scene);
  51357. /**
  51358. * Returns the texture matrix used in most of the material.
  51359. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51360. */
  51361. getTextureMatrix(): Matrix;
  51362. /**
  51363. * Occurs when the file being loaded is a .3dl LUT file.
  51364. */
  51365. private load3dlTexture;
  51366. /**
  51367. * Starts the loading process of the texture.
  51368. */
  51369. private loadTexture;
  51370. /**
  51371. * Clones the color gradind texture.
  51372. */
  51373. clone(): ColorGradingTexture;
  51374. /**
  51375. * Called during delayed load for textures.
  51376. */
  51377. delayLoad(): void;
  51378. /**
  51379. * Parses a color grading texture serialized by Babylon.
  51380. * @param parsedTexture The texture information being parsedTexture
  51381. * @param scene The scene to load the texture in
  51382. * @param rootUrl The root url of the data assets to load
  51383. * @return A color gradind texture
  51384. */
  51385. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51386. /**
  51387. * Serializes the LUT texture to json format.
  51388. */
  51389. serialize(): any;
  51390. }
  51391. }
  51392. declare module BABYLON {
  51393. /**
  51394. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51395. */
  51396. export class EquiRectangularCubeTexture extends BaseTexture {
  51397. /** The six faces of the cube. */
  51398. private static _FacesMapping;
  51399. private _noMipmap;
  51400. private _onLoad;
  51401. private _onError;
  51402. /** The size of the cubemap. */
  51403. private _size;
  51404. /** The buffer of the image. */
  51405. private _buffer;
  51406. /** The width of the input image. */
  51407. private _width;
  51408. /** The height of the input image. */
  51409. private _height;
  51410. /** The URL to the image. */
  51411. url: string;
  51412. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51413. coordinatesMode: number;
  51414. /**
  51415. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51416. * @param url The location of the image
  51417. * @param scene The scene the texture will be used in
  51418. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51419. * @param noMipmap Forces to not generate the mipmap if true
  51420. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51421. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51422. * @param onLoad — defines a callback called when texture is loaded
  51423. * @param onError — defines a callback called if there is an error
  51424. */
  51425. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51426. /**
  51427. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51428. */
  51429. private loadImage;
  51430. /**
  51431. * Convert the image buffer into a cubemap and create a CubeTexture.
  51432. */
  51433. private loadTexture;
  51434. /**
  51435. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51436. * @param buffer The ArrayBuffer that should be converted.
  51437. * @returns The buffer as Float32Array.
  51438. */
  51439. private getFloat32ArrayFromArrayBuffer;
  51440. /**
  51441. * Get the current class name of the texture useful for serialization or dynamic coding.
  51442. * @returns "EquiRectangularCubeTexture"
  51443. */
  51444. getClassName(): string;
  51445. /**
  51446. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51447. * @returns A clone of the current EquiRectangularCubeTexture.
  51448. */
  51449. clone(): EquiRectangularCubeTexture;
  51450. }
  51451. }
  51452. declare module BABYLON {
  51453. /**
  51454. * Based on jsTGALoader - Javascript loader for TGA file
  51455. * By Vincent Thibault
  51456. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51457. */
  51458. export class TGATools {
  51459. private static _TYPE_INDEXED;
  51460. private static _TYPE_RGB;
  51461. private static _TYPE_GREY;
  51462. private static _TYPE_RLE_INDEXED;
  51463. private static _TYPE_RLE_RGB;
  51464. private static _TYPE_RLE_GREY;
  51465. private static _ORIGIN_MASK;
  51466. private static _ORIGIN_SHIFT;
  51467. private static _ORIGIN_BL;
  51468. private static _ORIGIN_BR;
  51469. private static _ORIGIN_UL;
  51470. private static _ORIGIN_UR;
  51471. /**
  51472. * Gets the header of a TGA file
  51473. * @param data defines the TGA data
  51474. * @returns the header
  51475. */
  51476. static GetTGAHeader(data: Uint8Array): any;
  51477. /**
  51478. * Uploads TGA content to a Babylon Texture
  51479. * @hidden
  51480. */
  51481. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51482. /** @hidden */
  51483. 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;
  51484. /** @hidden */
  51485. 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;
  51486. /** @hidden */
  51487. 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;
  51488. /** @hidden */
  51489. 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;
  51490. /** @hidden */
  51491. 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;
  51492. /** @hidden */
  51493. 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;
  51494. }
  51495. }
  51496. declare module BABYLON {
  51497. /**
  51498. * Implementation of the TGA Texture Loader.
  51499. * @hidden
  51500. */
  51501. export class _TGATextureLoader implements IInternalTextureLoader {
  51502. /**
  51503. * Defines wether the loader supports cascade loading the different faces.
  51504. */
  51505. readonly supportCascades: boolean;
  51506. /**
  51507. * This returns if the loader support the current file information.
  51508. * @param extension defines the file extension of the file being loaded
  51509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51510. * @param fallback defines the fallback internal texture if any
  51511. * @param isBase64 defines whether the texture is encoded as a base64
  51512. * @param isBuffer defines whether the texture data are stored as a buffer
  51513. * @returns true if the loader can load the specified file
  51514. */
  51515. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51516. /**
  51517. * Transform the url before loading if required.
  51518. * @param rootUrl the url of the texture
  51519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51520. * @returns the transformed texture
  51521. */
  51522. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51523. /**
  51524. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51525. * @param rootUrl the url of the texture
  51526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51527. * @returns the fallback texture
  51528. */
  51529. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51530. /**
  51531. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51532. * @param data contains the texture data
  51533. * @param texture defines the BabylonJS internal texture
  51534. * @param createPolynomials will be true if polynomials have been requested
  51535. * @param onLoad defines the callback to trigger once the texture is ready
  51536. * @param onError defines the callback to trigger in case of error
  51537. */
  51538. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51539. /**
  51540. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51541. * @param data contains the texture data
  51542. * @param texture defines the BabylonJS internal texture
  51543. * @param callback defines the method to call once ready to upload
  51544. */
  51545. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51546. }
  51547. }
  51548. declare module BABYLON {
  51549. /**
  51550. * Info about the .basis files
  51551. */
  51552. class BasisFileInfo {
  51553. /**
  51554. * If the file has alpha
  51555. */
  51556. hasAlpha: boolean;
  51557. /**
  51558. * Info about each image of the basis file
  51559. */
  51560. images: Array<{
  51561. levels: Array<{
  51562. width: number;
  51563. height: number;
  51564. transcodedPixels: ArrayBufferView;
  51565. }>;
  51566. }>;
  51567. }
  51568. /**
  51569. * Result of transcoding a basis file
  51570. */
  51571. class TranscodeResult {
  51572. /**
  51573. * Info about the .basis file
  51574. */
  51575. fileInfo: BasisFileInfo;
  51576. /**
  51577. * Format to use when loading the file
  51578. */
  51579. format: number;
  51580. }
  51581. /**
  51582. * Configuration options for the Basis transcoder
  51583. */
  51584. export class BasisTranscodeConfiguration {
  51585. /**
  51586. * Supported compression formats used to determine the supported output format of the transcoder
  51587. */
  51588. supportedCompressionFormats?: {
  51589. /**
  51590. * etc1 compression format
  51591. */
  51592. etc1?: boolean;
  51593. /**
  51594. * s3tc compression format
  51595. */
  51596. s3tc?: boolean;
  51597. /**
  51598. * pvrtc compression format
  51599. */
  51600. pvrtc?: boolean;
  51601. /**
  51602. * etc2 compression format
  51603. */
  51604. etc2?: boolean;
  51605. };
  51606. /**
  51607. * If mipmap levels should be loaded for transcoded images (Default: true)
  51608. */
  51609. loadMipmapLevels?: boolean;
  51610. /**
  51611. * Index of a single image to load (Default: all images)
  51612. */
  51613. loadSingleImage?: number;
  51614. }
  51615. /**
  51616. * Used to load .Basis files
  51617. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51618. */
  51619. export class BasisTools {
  51620. private static _IgnoreSupportedFormats;
  51621. /**
  51622. * URL to use when loading the basis transcoder
  51623. */
  51624. static JSModuleURL: string;
  51625. /**
  51626. * URL to use when loading the wasm module for the transcoder
  51627. */
  51628. static WasmModuleURL: string;
  51629. /**
  51630. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51631. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51632. * @returns internal format corresponding to the Basis format
  51633. */
  51634. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51635. private static _WorkerPromise;
  51636. private static _Worker;
  51637. private static _actionId;
  51638. private static _CreateWorkerAsync;
  51639. /**
  51640. * Transcodes a loaded image file to compressed pixel data
  51641. * @param imageData image data to transcode
  51642. * @param config configuration options for the transcoding
  51643. * @returns a promise resulting in the transcoded image
  51644. */
  51645. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51646. /**
  51647. * Loads a texture from the transcode result
  51648. * @param texture texture load to
  51649. * @param transcodeResult the result of transcoding the basis file to load from
  51650. */
  51651. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51652. }
  51653. }
  51654. declare module BABYLON {
  51655. /**
  51656. * Loader for .basis file format
  51657. */
  51658. export class _BasisTextureLoader implements IInternalTextureLoader {
  51659. /**
  51660. * Defines whether the loader supports cascade loading the different faces.
  51661. */
  51662. readonly supportCascades: boolean;
  51663. /**
  51664. * This returns if the loader support the current file information.
  51665. * @param extension defines the file extension of the file being loaded
  51666. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51667. * @param fallback defines the fallback internal texture if any
  51668. * @param isBase64 defines whether the texture is encoded as a base64
  51669. * @param isBuffer defines whether the texture data are stored as a buffer
  51670. * @returns true if the loader can load the specified file
  51671. */
  51672. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51673. /**
  51674. * Transform the url before loading if required.
  51675. * @param rootUrl the url of the texture
  51676. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51677. * @returns the transformed texture
  51678. */
  51679. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51680. /**
  51681. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51682. * @param rootUrl the url of the texture
  51683. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51684. * @returns the fallback texture
  51685. */
  51686. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51687. /**
  51688. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51689. * @param data contains the texture data
  51690. * @param texture defines the BabylonJS internal texture
  51691. * @param createPolynomials will be true if polynomials have been requested
  51692. * @param onLoad defines the callback to trigger once the texture is ready
  51693. * @param onError defines the callback to trigger in case of error
  51694. */
  51695. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51696. /**
  51697. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51698. * @param data contains the texture data
  51699. * @param texture defines the BabylonJS internal texture
  51700. * @param callback defines the method to call once ready to upload
  51701. */
  51702. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51703. }
  51704. }
  51705. declare module BABYLON {
  51706. /**
  51707. * 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.
  51708. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51709. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51710. */
  51711. export class CustomProceduralTexture extends ProceduralTexture {
  51712. private _animate;
  51713. private _time;
  51714. private _config;
  51715. private _texturePath;
  51716. /**
  51717. * Instantiates a new Custom Procedural Texture.
  51718. * 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.
  51719. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51720. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51721. * @param name Define the name of the texture
  51722. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51723. * @param size Define the size of the texture to create
  51724. * @param scene Define the scene the texture belongs to
  51725. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51726. * @param generateMipMaps Define if the texture should creates mip maps or not
  51727. */
  51728. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51729. private _loadJson;
  51730. /**
  51731. * Is the texture ready to be used ? (rendered at least once)
  51732. * @returns true if ready, otherwise, false.
  51733. */
  51734. isReady(): boolean;
  51735. /**
  51736. * Render the texture to its associated render target.
  51737. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51738. */
  51739. render(useCameraPostProcess?: boolean): void;
  51740. /**
  51741. * Update the list of dependant textures samplers in the shader.
  51742. */
  51743. updateTextures(): void;
  51744. /**
  51745. * Update the uniform values of the procedural texture in the shader.
  51746. */
  51747. updateShaderUniforms(): void;
  51748. /**
  51749. * Define if the texture animates or not.
  51750. */
  51751. animate: boolean;
  51752. }
  51753. }
  51754. declare module BABYLON {
  51755. /** @hidden */
  51756. export var noisePixelShader: {
  51757. name: string;
  51758. shader: string;
  51759. };
  51760. }
  51761. declare module BABYLON {
  51762. /**
  51763. * Class used to generate noise procedural textures
  51764. */
  51765. export class NoiseProceduralTexture extends ProceduralTexture {
  51766. private _time;
  51767. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51768. brightness: number;
  51769. /** Defines the number of octaves to process */
  51770. octaves: number;
  51771. /** Defines the level of persistence (0.8 by default) */
  51772. persistence: number;
  51773. /** Gets or sets animation speed factor (default is 1) */
  51774. animationSpeedFactor: number;
  51775. /**
  51776. * Creates a new NoiseProceduralTexture
  51777. * @param name defines the name fo the texture
  51778. * @param size defines the size of the texture (default is 256)
  51779. * @param scene defines the hosting scene
  51780. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51781. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51782. */
  51783. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51784. private _updateShaderUniforms;
  51785. protected _getDefines(): string;
  51786. /** Generate the current state of the procedural texture */
  51787. render(useCameraPostProcess?: boolean): void;
  51788. /**
  51789. * Serializes this noise procedural texture
  51790. * @returns a serialized noise procedural texture object
  51791. */
  51792. serialize(): any;
  51793. /**
  51794. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51795. * @param parsedTexture defines parsed texture data
  51796. * @param scene defines the current scene
  51797. * @param rootUrl defines the root URL containing noise procedural texture information
  51798. * @returns a parsed NoiseProceduralTexture
  51799. */
  51800. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51801. }
  51802. }
  51803. declare module BABYLON {
  51804. /**
  51805. * Raw cube texture where the raw buffers are passed in
  51806. */
  51807. export class RawCubeTexture extends CubeTexture {
  51808. /**
  51809. * Creates a cube texture where the raw buffers are passed in.
  51810. * @param scene defines the scene the texture is attached to
  51811. * @param data defines the array of data to use to create each face
  51812. * @param size defines the size of the textures
  51813. * @param format defines the format of the data
  51814. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51815. * @param generateMipMaps defines if the engine should generate the mip levels
  51816. * @param invertY defines if data must be stored with Y axis inverted
  51817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51818. * @param compression defines the compression used (null by default)
  51819. */
  51820. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51821. /**
  51822. * Updates the raw cube texture.
  51823. * @param data defines the data to store
  51824. * @param format defines the data format
  51825. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51826. * @param invertY defines if data must be stored with Y axis inverted
  51827. * @param compression defines the compression used (null by default)
  51828. * @param level defines which level of the texture to update
  51829. */
  51830. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51831. /**
  51832. * Updates a raw cube texture with RGBD encoded data.
  51833. * @param data defines the array of data [mipmap][face] to use to create each face
  51834. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51835. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51836. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51837. * @returns a promsie that resolves when the operation is complete
  51838. */
  51839. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51840. /**
  51841. * Clones the raw cube texture.
  51842. * @return a new cube texture
  51843. */
  51844. clone(): CubeTexture;
  51845. /** @hidden */
  51846. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51847. }
  51848. }
  51849. declare module BABYLON {
  51850. /**
  51851. * Class used to store 3D textures containing user data
  51852. */
  51853. export class RawTexture3D extends Texture {
  51854. /** Gets or sets the texture format to use */
  51855. format: number;
  51856. private _engine;
  51857. /**
  51858. * Create a new RawTexture3D
  51859. * @param data defines the data of the texture
  51860. * @param width defines the width of the texture
  51861. * @param height defines the height of the texture
  51862. * @param depth defines the depth of the texture
  51863. * @param format defines the texture format to use
  51864. * @param scene defines the hosting scene
  51865. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51866. * @param invertY defines if texture must be stored with Y axis inverted
  51867. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51868. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51869. */
  51870. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51871. /** Gets or sets the texture format to use */
  51872. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51873. /**
  51874. * Update the texture with new data
  51875. * @param data defines the data to store in the texture
  51876. */
  51877. update(data: ArrayBufferView): void;
  51878. }
  51879. }
  51880. declare module BABYLON {
  51881. /**
  51882. * Creates a refraction texture used by refraction channel of the standard material.
  51883. * It is like a mirror but to see through a material.
  51884. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51885. */
  51886. export class RefractionTexture extends RenderTargetTexture {
  51887. /**
  51888. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51889. * 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.
  51890. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51891. */
  51892. refractionPlane: Plane;
  51893. /**
  51894. * Define how deep under the surface we should see.
  51895. */
  51896. depth: number;
  51897. /**
  51898. * Creates a refraction texture used by refraction channel of the standard material.
  51899. * It is like a mirror but to see through a material.
  51900. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51901. * @param name Define the texture name
  51902. * @param size Define the size of the underlying texture
  51903. * @param scene Define the scene the refraction belongs to
  51904. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51905. */
  51906. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51907. /**
  51908. * Clone the refraction texture.
  51909. * @returns the cloned texture
  51910. */
  51911. clone(): RefractionTexture;
  51912. /**
  51913. * Serialize the texture to a JSON representation you could use in Parse later on
  51914. * @returns the serialized JSON representation
  51915. */
  51916. serialize(): any;
  51917. }
  51918. }
  51919. declare module BABYLON {
  51920. /**
  51921. * Defines the options related to the creation of an HtmlElementTexture
  51922. */
  51923. export interface IHtmlElementTextureOptions {
  51924. /**
  51925. * Defines wether mip maps should be created or not.
  51926. */
  51927. generateMipMaps?: boolean;
  51928. /**
  51929. * Defines the sampling mode of the texture.
  51930. */
  51931. samplingMode?: number;
  51932. /**
  51933. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51934. */
  51935. engine: Nullable<Engine>;
  51936. /**
  51937. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51938. */
  51939. scene: Nullable<Scene>;
  51940. }
  51941. /**
  51942. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51943. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51944. * is automatically managed.
  51945. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51946. * in your application.
  51947. *
  51948. * As the update is not automatic, you need to call them manually.
  51949. */
  51950. export class HtmlElementTexture extends BaseTexture {
  51951. /**
  51952. * The texture URL.
  51953. */
  51954. element: HTMLVideoElement | HTMLCanvasElement;
  51955. private static readonly DefaultOptions;
  51956. private _textureMatrix;
  51957. private _engine;
  51958. private _isVideo;
  51959. private _generateMipMaps;
  51960. private _samplingMode;
  51961. /**
  51962. * Instantiates a HtmlElementTexture from the following parameters.
  51963. *
  51964. * @param name Defines the name of the texture
  51965. * @param element Defines the video or canvas the texture is filled with
  51966. * @param options Defines the other none mandatory texture creation options
  51967. */
  51968. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51969. private _createInternalTexture;
  51970. /**
  51971. * Returns the texture matrix used in most of the material.
  51972. */
  51973. getTextureMatrix(): Matrix;
  51974. /**
  51975. * Updates the content of the texture.
  51976. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51977. */
  51978. update(invertY?: Nullable<boolean>): void;
  51979. }
  51980. }
  51981. declare module BABYLON {
  51982. /**
  51983. * Enum used to define the target of a block
  51984. */
  51985. export enum NodeMaterialBlockTargets {
  51986. /** Vertex shader */
  51987. Vertex = 1,
  51988. /** Fragment shader */
  51989. Fragment = 2,
  51990. /** Neutral */
  51991. Neutral = 4,
  51992. /** Vertex and Fragment */
  51993. VertexAndFragment = 3
  51994. }
  51995. }
  51996. declare module BABYLON {
  51997. /**
  51998. * Defines the kind of connection point for node based material
  51999. */
  52000. export enum NodeMaterialBlockConnectionPointTypes {
  52001. /** Float */
  52002. Float = 1,
  52003. /** Int */
  52004. Int = 2,
  52005. /** Vector2 */
  52006. Vector2 = 4,
  52007. /** Vector3 */
  52008. Vector3 = 8,
  52009. /** Vector4 */
  52010. Vector4 = 16,
  52011. /** Color3 */
  52012. Color3 = 32,
  52013. /** Color4 */
  52014. Color4 = 64,
  52015. /** Matrix */
  52016. Matrix = 128,
  52017. /** Detect type based on connection */
  52018. AutoDetect = 1024,
  52019. /** Output type that will be defined by input type */
  52020. BasedOnInput = 2048
  52021. }
  52022. }
  52023. declare module BABYLON {
  52024. /**
  52025. * Root class for all node material optimizers
  52026. */
  52027. export class NodeMaterialOptimizer {
  52028. /**
  52029. * Function used to optimize a NodeMaterial graph
  52030. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52031. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52032. */
  52033. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52034. }
  52035. }
  52036. declare module BABYLON {
  52037. /**
  52038. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52039. */
  52040. export class TransformBlock extends NodeMaterialBlock {
  52041. /**
  52042. * Defines the value to use to complement W value to transform it to a Vector4
  52043. */
  52044. complementW: number;
  52045. /**
  52046. * Defines the value to use to complement z value to transform it to a Vector4
  52047. */
  52048. complementZ: number;
  52049. /**
  52050. * Creates a new TransformBlock
  52051. * @param name defines the block name
  52052. */
  52053. constructor(name: string);
  52054. /**
  52055. * Gets the current class name
  52056. * @returns the class name
  52057. */
  52058. getClassName(): string;
  52059. /**
  52060. * Gets the vector input
  52061. */
  52062. readonly vector: NodeMaterialConnectionPoint;
  52063. /**
  52064. * Gets the output component
  52065. */
  52066. readonly output: NodeMaterialConnectionPoint;
  52067. /**
  52068. * Gets the matrix transform input
  52069. */
  52070. readonly transform: NodeMaterialConnectionPoint;
  52071. protected _buildBlock(state: NodeMaterialBuildState): this;
  52072. serialize(): any;
  52073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52074. protected _dumpPropertiesCode(): string;
  52075. }
  52076. }
  52077. declare module BABYLON {
  52078. /**
  52079. * Block used to output the vertex position
  52080. */
  52081. export class VertexOutputBlock extends NodeMaterialBlock {
  52082. /**
  52083. * Creates a new VertexOutputBlock
  52084. * @param name defines the block name
  52085. */
  52086. constructor(name: string);
  52087. /**
  52088. * Gets the current class name
  52089. * @returns the class name
  52090. */
  52091. getClassName(): string;
  52092. /**
  52093. * Gets the vector input component
  52094. */
  52095. readonly vector: NodeMaterialConnectionPoint;
  52096. protected _buildBlock(state: NodeMaterialBuildState): this;
  52097. }
  52098. }
  52099. declare module BABYLON {
  52100. /**
  52101. * Block used to output the final color
  52102. */
  52103. export class FragmentOutputBlock extends NodeMaterialBlock {
  52104. /**
  52105. * Create a new FragmentOutputBlock
  52106. * @param name defines the block name
  52107. */
  52108. constructor(name: string);
  52109. /**
  52110. * Gets the current class name
  52111. * @returns the class name
  52112. */
  52113. getClassName(): string;
  52114. /**
  52115. * Gets the rgba input component
  52116. */
  52117. readonly rgba: NodeMaterialConnectionPoint;
  52118. /**
  52119. * Gets the rgb input component
  52120. */
  52121. readonly rgb: NodeMaterialConnectionPoint;
  52122. /**
  52123. * Gets the a input component
  52124. */
  52125. readonly a: NodeMaterialConnectionPoint;
  52126. protected _buildBlock(state: NodeMaterialBuildState): this;
  52127. }
  52128. }
  52129. declare module BABYLON {
  52130. /**
  52131. * Enum used to define system values e.g. values automatically provided by the system
  52132. */
  52133. export enum NodeMaterialSystemValues {
  52134. /** World */
  52135. World = 1,
  52136. /** View */
  52137. View = 2,
  52138. /** Projection */
  52139. Projection = 3,
  52140. /** ViewProjection */
  52141. ViewProjection = 4,
  52142. /** WorldView */
  52143. WorldView = 5,
  52144. /** WorldViewProjection */
  52145. WorldViewProjection = 6,
  52146. /** CameraPosition */
  52147. CameraPosition = 7,
  52148. /** Fog Color */
  52149. FogColor = 8
  52150. }
  52151. }
  52152. declare module BABYLON {
  52153. /**
  52154. * Block used to read a reflection texture from a sampler
  52155. */
  52156. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52157. private _define3DName;
  52158. private _defineCubicName;
  52159. private _defineExplicitName;
  52160. private _defineProjectionName;
  52161. private _defineLocalCubicName;
  52162. private _defineSphericalName;
  52163. private _definePlanarName;
  52164. private _defineEquirectangularName;
  52165. private _defineMirroredEquirectangularFixedName;
  52166. private _defineEquirectangularFixedName;
  52167. private _defineSkyboxName;
  52168. private _cubeSamplerName;
  52169. private _2DSamplerName;
  52170. private _positionUVWName;
  52171. private _directionWName;
  52172. private _reflectionCoordsName;
  52173. private _reflection2DCoordsName;
  52174. private _reflectionColorName;
  52175. private _reflectionMatrixName;
  52176. /**
  52177. * Gets or sets the texture associated with the node
  52178. */
  52179. texture: Nullable<BaseTexture>;
  52180. /**
  52181. * Create a new TextureBlock
  52182. * @param name defines the block name
  52183. */
  52184. constructor(name: string);
  52185. /**
  52186. * Gets the current class name
  52187. * @returns the class name
  52188. */
  52189. getClassName(): string;
  52190. /**
  52191. * Gets the world position input component
  52192. */
  52193. readonly position: NodeMaterialConnectionPoint;
  52194. /**
  52195. * Gets the world position input component
  52196. */
  52197. readonly worldPosition: NodeMaterialConnectionPoint;
  52198. /**
  52199. * Gets the world normal input component
  52200. */
  52201. readonly worldNormal: NodeMaterialConnectionPoint;
  52202. /**
  52203. * Gets the world input component
  52204. */
  52205. readonly world: NodeMaterialConnectionPoint;
  52206. /**
  52207. * Gets the camera (or eye) position component
  52208. */
  52209. readonly cameraPosition: NodeMaterialConnectionPoint;
  52210. /**
  52211. * Gets the view input component
  52212. */
  52213. readonly view: NodeMaterialConnectionPoint;
  52214. /**
  52215. * Gets the rgb output component
  52216. */
  52217. readonly rgb: NodeMaterialConnectionPoint;
  52218. /**
  52219. * Gets the r output component
  52220. */
  52221. readonly r: NodeMaterialConnectionPoint;
  52222. /**
  52223. * Gets the g output component
  52224. */
  52225. readonly g: NodeMaterialConnectionPoint;
  52226. /**
  52227. * Gets the b output component
  52228. */
  52229. readonly b: NodeMaterialConnectionPoint;
  52230. autoConfigure(material: NodeMaterial): void;
  52231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52232. isReady(): boolean;
  52233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52234. private _injectVertexCode;
  52235. private _writeOutput;
  52236. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52237. serialize(): any;
  52238. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52239. }
  52240. }
  52241. declare module BABYLON {
  52242. /**
  52243. * Interface used to configure the node material editor
  52244. */
  52245. export interface INodeMaterialEditorOptions {
  52246. /** Define the URl to load node editor script */
  52247. editorURL?: string;
  52248. }
  52249. /** @hidden */
  52250. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52251. /** BONES */
  52252. NUM_BONE_INFLUENCERS: number;
  52253. BonesPerMesh: number;
  52254. BONETEXTURE: boolean;
  52255. /** MORPH TARGETS */
  52256. MORPHTARGETS: boolean;
  52257. MORPHTARGETS_NORMAL: boolean;
  52258. MORPHTARGETS_TANGENT: boolean;
  52259. MORPHTARGETS_UV: boolean;
  52260. NUM_MORPH_INFLUENCERS: number;
  52261. /** IMAGE PROCESSING */
  52262. IMAGEPROCESSING: boolean;
  52263. VIGNETTE: boolean;
  52264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52265. VIGNETTEBLENDMODEOPAQUE: boolean;
  52266. TONEMAPPING: boolean;
  52267. TONEMAPPING_ACES: boolean;
  52268. CONTRAST: boolean;
  52269. EXPOSURE: boolean;
  52270. COLORCURVES: boolean;
  52271. COLORGRADING: boolean;
  52272. COLORGRADING3D: boolean;
  52273. SAMPLER3DGREENDEPTH: boolean;
  52274. SAMPLER3DBGRMAP: boolean;
  52275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52276. /** MISC. */
  52277. BUMPDIRECTUV: number;
  52278. constructor();
  52279. setValue(name: string, value: boolean): void;
  52280. }
  52281. /**
  52282. * Class used to configure NodeMaterial
  52283. */
  52284. export interface INodeMaterialOptions {
  52285. /**
  52286. * Defines if blocks should emit comments
  52287. */
  52288. emitComments: boolean;
  52289. }
  52290. /**
  52291. * Class used to create a node based material built by assembling shader blocks
  52292. */
  52293. export class NodeMaterial extends PushMaterial {
  52294. private static _BuildIdGenerator;
  52295. private _options;
  52296. private _vertexCompilationState;
  52297. private _fragmentCompilationState;
  52298. private _sharedData;
  52299. private _buildId;
  52300. private _buildWasSuccessful;
  52301. private _cachedWorldViewMatrix;
  52302. private _cachedWorldViewProjectionMatrix;
  52303. private _optimizers;
  52304. private _animationFrame;
  52305. /** Define the URl to load node editor script */
  52306. static EditorURL: string;
  52307. private BJSNODEMATERIALEDITOR;
  52308. /** Get the inspector from bundle or global */
  52309. private _getGlobalNodeMaterialEditor;
  52310. /**
  52311. * 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)
  52312. */
  52313. ignoreAlpha: boolean;
  52314. /**
  52315. * Defines the maximum number of lights that can be used in the material
  52316. */
  52317. maxSimultaneousLights: number;
  52318. /**
  52319. * Observable raised when the material is built
  52320. */
  52321. onBuildObservable: Observable<NodeMaterial>;
  52322. /**
  52323. * Gets or sets the root nodes of the material vertex shader
  52324. */
  52325. _vertexOutputNodes: NodeMaterialBlock[];
  52326. /**
  52327. * Gets or sets the root nodes of the material fragment (pixel) shader
  52328. */
  52329. _fragmentOutputNodes: NodeMaterialBlock[];
  52330. /** Gets or sets options to control the node material overall behavior */
  52331. options: INodeMaterialOptions;
  52332. /**
  52333. * Default configuration related to image processing available in the standard Material.
  52334. */
  52335. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52336. /**
  52337. * Gets the image processing configuration used either in this material.
  52338. */
  52339. /**
  52340. * Sets the Default image processing configuration used either in the this material.
  52341. *
  52342. * If sets to null, the scene one is in use.
  52343. */
  52344. imageProcessingConfiguration: ImageProcessingConfiguration;
  52345. /**
  52346. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52347. */
  52348. attachedBlocks: NodeMaterialBlock[];
  52349. /**
  52350. * Create a new node based material
  52351. * @param name defines the material name
  52352. * @param scene defines the hosting scene
  52353. * @param options defines creation option
  52354. */
  52355. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52356. /**
  52357. * Gets the current class name of the material e.g. "NodeMaterial"
  52358. * @returns the class name
  52359. */
  52360. getClassName(): string;
  52361. /**
  52362. * Keep track of the image processing observer to allow dispose and replace.
  52363. */
  52364. private _imageProcessingObserver;
  52365. /**
  52366. * Attaches a new image processing configuration to the Standard Material.
  52367. * @param configuration
  52368. */
  52369. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52370. /**
  52371. * Get a block by its name
  52372. * @param name defines the name of the block to retrieve
  52373. * @returns the required block or null if not found
  52374. */
  52375. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52376. /**
  52377. * Get a block by its name
  52378. * @param predicate defines the predicate used to find the good candidate
  52379. * @returns the required block or null if not found
  52380. */
  52381. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52382. /**
  52383. * Get an input block by its name
  52384. * @param predicate defines the predicate used to find the good candidate
  52385. * @returns the required input block or null if not found
  52386. */
  52387. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52388. /**
  52389. * Gets the list of input blocks attached to this material
  52390. * @returns an array of InputBlocks
  52391. */
  52392. getInputBlocks(): InputBlock[];
  52393. /**
  52394. * Adds a new optimizer to the list of optimizers
  52395. * @param optimizer defines the optimizers to add
  52396. * @returns the current material
  52397. */
  52398. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52399. /**
  52400. * Remove an optimizer from the list of optimizers
  52401. * @param optimizer defines the optimizers to remove
  52402. * @returns the current material
  52403. */
  52404. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52405. /**
  52406. * Add a new block to the list of output nodes
  52407. * @param node defines the node to add
  52408. * @returns the current material
  52409. */
  52410. addOutputNode(node: NodeMaterialBlock): this;
  52411. /**
  52412. * Remove a block from the list of root nodes
  52413. * @param node defines the node to remove
  52414. * @returns the current material
  52415. */
  52416. removeOutputNode(node: NodeMaterialBlock): this;
  52417. private _addVertexOutputNode;
  52418. private _removeVertexOutputNode;
  52419. private _addFragmentOutputNode;
  52420. private _removeFragmentOutputNode;
  52421. /**
  52422. * Specifies if the material will require alpha blending
  52423. * @returns a boolean specifying if alpha blending is needed
  52424. */
  52425. needAlphaBlending(): boolean;
  52426. /**
  52427. * Specifies if this material should be rendered in alpha test mode
  52428. * @returns a boolean specifying if an alpha test is needed.
  52429. */
  52430. needAlphaTesting(): boolean;
  52431. private _initializeBlock;
  52432. private _resetDualBlocks;
  52433. /**
  52434. * Build the material and generates the inner effect
  52435. * @param verbose defines if the build should log activity
  52436. */
  52437. build(verbose?: boolean): void;
  52438. /**
  52439. * Runs an otpimization phase to try to improve the shader code
  52440. */
  52441. optimize(): void;
  52442. private _prepareDefinesForAttributes;
  52443. /**
  52444. * Get if the submesh is ready to be used and all its information available.
  52445. * Child classes can use it to update shaders
  52446. * @param mesh defines the mesh to check
  52447. * @param subMesh defines which submesh to check
  52448. * @param useInstances specifies that instances should be used
  52449. * @returns a boolean indicating that the submesh is ready or not
  52450. */
  52451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52452. /**
  52453. * Get a string representing the shaders built by the current node graph
  52454. */
  52455. readonly compiledShaders: string;
  52456. /**
  52457. * Binds the world matrix to the material
  52458. * @param world defines the world transformation matrix
  52459. */
  52460. bindOnlyWorldMatrix(world: Matrix): void;
  52461. /**
  52462. * Binds the submesh to this material by preparing the effect and shader to draw
  52463. * @param world defines the world transformation matrix
  52464. * @param mesh defines the mesh containing the submesh
  52465. * @param subMesh defines the submesh to bind the material to
  52466. */
  52467. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52468. /**
  52469. * Gets the active textures from the material
  52470. * @returns an array of textures
  52471. */
  52472. getActiveTextures(): BaseTexture[];
  52473. /**
  52474. * Gets the list of texture blocks
  52475. * @returns an array of texture blocks
  52476. */
  52477. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52478. /**
  52479. * Specifies if the material uses a texture
  52480. * @param texture defines the texture to check against the material
  52481. * @returns a boolean specifying if the material uses the texture
  52482. */
  52483. hasTexture(texture: BaseTexture): boolean;
  52484. /**
  52485. * Disposes the material
  52486. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52487. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52488. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52489. */
  52490. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52491. /** Creates the node editor window. */
  52492. private _createNodeEditor;
  52493. /**
  52494. * Launch the node material editor
  52495. * @param config Define the configuration of the editor
  52496. * @return a promise fulfilled when the node editor is visible
  52497. */
  52498. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52499. /**
  52500. * Clear the current material
  52501. */
  52502. clear(): void;
  52503. /**
  52504. * Clear the current material and set it to a default state
  52505. */
  52506. setToDefault(): void;
  52507. /**
  52508. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52509. * @param url defines the url to load from
  52510. * @returns a promise that will fullfil when the material is fully loaded
  52511. */
  52512. loadAsync(url: string): Promise<unknown>;
  52513. private _gatherBlocks;
  52514. /**
  52515. * Generate a string containing the code declaration required to create an equivalent of this material
  52516. * @returns a string
  52517. */
  52518. generateCode(): string;
  52519. /**
  52520. * Serializes this material in a JSON representation
  52521. * @returns the serialized material object
  52522. */
  52523. serialize(): any;
  52524. private _restoreConnections;
  52525. /**
  52526. * Clear the current graph and load a new one from a serialization object
  52527. * @param source defines the JSON representation of the material
  52528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52529. */
  52530. loadFromSerialization(source: any, rootUrl?: string): void;
  52531. /**
  52532. * Creates a node material from parsed material data
  52533. * @param source defines the JSON representation of the material
  52534. * @param scene defines the hosting scene
  52535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52536. * @returns a new node material
  52537. */
  52538. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52539. /**
  52540. * Creates a new node material set to default basic configuration
  52541. * @param name defines the name of the material
  52542. * @param scene defines the hosting scene
  52543. * @returns a new NodeMaterial
  52544. */
  52545. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52546. }
  52547. }
  52548. declare module BABYLON {
  52549. /**
  52550. * Block used to read a texture from a sampler
  52551. */
  52552. export class TextureBlock extends NodeMaterialBlock {
  52553. private _defineName;
  52554. private _samplerName;
  52555. private _transformedUVName;
  52556. private _textureTransformName;
  52557. private _textureInfoName;
  52558. private _mainUVName;
  52559. private _mainUVDefineName;
  52560. /**
  52561. * Gets or sets the texture associated with the node
  52562. */
  52563. texture: Nullable<Texture>;
  52564. /**
  52565. * Create a new TextureBlock
  52566. * @param name defines the block name
  52567. */
  52568. constructor(name: string);
  52569. /**
  52570. * Gets the current class name
  52571. * @returns the class name
  52572. */
  52573. getClassName(): string;
  52574. /**
  52575. * Gets the uv input component
  52576. */
  52577. readonly uv: NodeMaterialConnectionPoint;
  52578. /**
  52579. * Gets the rgba output component
  52580. */
  52581. readonly rgba: NodeMaterialConnectionPoint;
  52582. /**
  52583. * Gets the rgb output component
  52584. */
  52585. readonly rgb: NodeMaterialConnectionPoint;
  52586. /**
  52587. * Gets the r output component
  52588. */
  52589. readonly r: NodeMaterialConnectionPoint;
  52590. /**
  52591. * Gets the g output component
  52592. */
  52593. readonly g: NodeMaterialConnectionPoint;
  52594. /**
  52595. * Gets the b output component
  52596. */
  52597. readonly b: NodeMaterialConnectionPoint;
  52598. /**
  52599. * Gets the a output component
  52600. */
  52601. readonly a: NodeMaterialConnectionPoint;
  52602. readonly target: NodeMaterialBlockTargets;
  52603. autoConfigure(material: NodeMaterial): void;
  52604. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52605. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52606. isReady(): boolean;
  52607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52608. private readonly _isMixed;
  52609. private _injectVertexCode;
  52610. private _writeOutput;
  52611. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52612. protected _dumpPropertiesCode(): string;
  52613. serialize(): any;
  52614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52615. }
  52616. }
  52617. declare module BABYLON {
  52618. /**
  52619. * Class used to store shared data between 2 NodeMaterialBuildState
  52620. */
  52621. export class NodeMaterialBuildStateSharedData {
  52622. /**
  52623. * Gets the list of emitted varyings
  52624. */
  52625. temps: string[];
  52626. /**
  52627. * Gets the list of emitted varyings
  52628. */
  52629. varyings: string[];
  52630. /**
  52631. * Gets the varying declaration string
  52632. */
  52633. varyingDeclaration: string;
  52634. /**
  52635. * Input blocks
  52636. */
  52637. inputBlocks: InputBlock[];
  52638. /**
  52639. * Input blocks
  52640. */
  52641. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52642. /**
  52643. * Bindable blocks (Blocks that need to set data to the effect)
  52644. */
  52645. bindableBlocks: NodeMaterialBlock[];
  52646. /**
  52647. * List of blocks that can provide a compilation fallback
  52648. */
  52649. blocksWithFallbacks: NodeMaterialBlock[];
  52650. /**
  52651. * List of blocks that can provide a define update
  52652. */
  52653. blocksWithDefines: NodeMaterialBlock[];
  52654. /**
  52655. * List of blocks that can provide a repeatable content
  52656. */
  52657. repeatableContentBlocks: NodeMaterialBlock[];
  52658. /**
  52659. * List of blocks that can provide a dynamic list of uniforms
  52660. */
  52661. dynamicUniformBlocks: NodeMaterialBlock[];
  52662. /**
  52663. * List of blocks that can block the isReady function for the material
  52664. */
  52665. blockingBlocks: NodeMaterialBlock[];
  52666. /**
  52667. * Gets the list of animated inputs
  52668. */
  52669. animatedInputs: InputBlock[];
  52670. /**
  52671. * Build Id used to avoid multiple recompilations
  52672. */
  52673. buildId: number;
  52674. /** List of emitted variables */
  52675. variableNames: {
  52676. [key: string]: number;
  52677. };
  52678. /** List of emitted defines */
  52679. defineNames: {
  52680. [key: string]: number;
  52681. };
  52682. /** Should emit comments? */
  52683. emitComments: boolean;
  52684. /** Emit build activity */
  52685. verbose: boolean;
  52686. /**
  52687. * Gets the compilation hints emitted at compilation time
  52688. */
  52689. hints: {
  52690. needWorldViewMatrix: boolean;
  52691. needWorldViewProjectionMatrix: boolean;
  52692. needAlphaBlending: boolean;
  52693. needAlphaTesting: boolean;
  52694. };
  52695. /**
  52696. * List of compilation checks
  52697. */
  52698. checks: {
  52699. emitVertex: boolean;
  52700. emitFragment: boolean;
  52701. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52702. };
  52703. /** Creates a new shared data */
  52704. constructor();
  52705. /**
  52706. * Emits console errors and exceptions if there is a failing check
  52707. */
  52708. emitErrors(): void;
  52709. }
  52710. }
  52711. declare module BABYLON {
  52712. /**
  52713. * Class used to store node based material build state
  52714. */
  52715. export class NodeMaterialBuildState {
  52716. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52717. supportUniformBuffers: boolean;
  52718. /**
  52719. * Gets the list of emitted attributes
  52720. */
  52721. attributes: string[];
  52722. /**
  52723. * Gets the list of emitted uniforms
  52724. */
  52725. uniforms: string[];
  52726. /**
  52727. * Gets the list of emitted uniform buffers
  52728. */
  52729. uniformBuffers: string[];
  52730. /**
  52731. * Gets the list of emitted samplers
  52732. */
  52733. samplers: string[];
  52734. /**
  52735. * Gets the list of emitted functions
  52736. */
  52737. functions: {
  52738. [key: string]: string;
  52739. };
  52740. /**
  52741. * Gets the list of emitted extensions
  52742. */
  52743. extensions: {
  52744. [key: string]: string;
  52745. };
  52746. /**
  52747. * Gets the target of the compilation state
  52748. */
  52749. target: NodeMaterialBlockTargets;
  52750. /**
  52751. * Gets the list of emitted counters
  52752. */
  52753. counters: {
  52754. [key: string]: number;
  52755. };
  52756. /**
  52757. * Shared data between multiple NodeMaterialBuildState instances
  52758. */
  52759. sharedData: NodeMaterialBuildStateSharedData;
  52760. /** @hidden */
  52761. _vertexState: NodeMaterialBuildState;
  52762. /** @hidden */
  52763. _attributeDeclaration: string;
  52764. /** @hidden */
  52765. _uniformDeclaration: string;
  52766. /** @hidden */
  52767. _samplerDeclaration: string;
  52768. /** @hidden */
  52769. _varyingTransfer: string;
  52770. private _repeatableContentAnchorIndex;
  52771. /** @hidden */
  52772. _builtCompilationString: string;
  52773. /**
  52774. * Gets the emitted compilation strings
  52775. */
  52776. compilationString: string;
  52777. /**
  52778. * Finalize the compilation strings
  52779. * @param state defines the current compilation state
  52780. */
  52781. finalize(state: NodeMaterialBuildState): void;
  52782. /** @hidden */
  52783. readonly _repeatableContentAnchor: string;
  52784. /** @hidden */
  52785. _getFreeVariableName(prefix: string): string;
  52786. /** @hidden */
  52787. _getFreeDefineName(prefix: string): string;
  52788. /** @hidden */
  52789. _excludeVariableName(name: string): void;
  52790. /** @hidden */
  52791. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52792. /** @hidden */
  52793. _emitExtension(name: string, extension: string): void;
  52794. /** @hidden */
  52795. _emitFunction(name: string, code: string, comments: string): void;
  52796. /** @hidden */
  52797. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52798. replaceStrings?: {
  52799. search: RegExp;
  52800. replace: string;
  52801. }[];
  52802. repeatKey?: string;
  52803. }): string;
  52804. /** @hidden */
  52805. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52806. repeatKey?: string;
  52807. removeAttributes?: boolean;
  52808. removeUniforms?: boolean;
  52809. removeVaryings?: boolean;
  52810. removeIfDef?: boolean;
  52811. replaceStrings?: {
  52812. search: RegExp;
  52813. replace: string;
  52814. }[];
  52815. }, storeKey?: string): void;
  52816. /** @hidden */
  52817. _registerTempVariable(name: string): boolean;
  52818. /** @hidden */
  52819. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52820. /** @hidden */
  52821. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52822. }
  52823. }
  52824. declare module BABYLON {
  52825. /**
  52826. * Defines a block that can be used inside a node based material
  52827. */
  52828. export class NodeMaterialBlock {
  52829. private _buildId;
  52830. private _buildTarget;
  52831. private _target;
  52832. private _isFinalMerger;
  52833. private _isInput;
  52834. /** @hidden */
  52835. _codeVariableName: string;
  52836. /** @hidden */
  52837. _inputs: NodeMaterialConnectionPoint[];
  52838. /** @hidden */
  52839. _outputs: NodeMaterialConnectionPoint[];
  52840. /** @hidden */
  52841. _preparationId: number;
  52842. /**
  52843. * Gets or sets the name of the block
  52844. */
  52845. name: string;
  52846. /**
  52847. * Gets or sets the unique id of the node
  52848. */
  52849. uniqueId: number;
  52850. /**
  52851. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52852. */
  52853. readonly isFinalMerger: boolean;
  52854. /**
  52855. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52856. */
  52857. readonly isInput: boolean;
  52858. /**
  52859. * Gets or sets the build Id
  52860. */
  52861. buildId: number;
  52862. /**
  52863. * Gets or sets the target of the block
  52864. */
  52865. target: NodeMaterialBlockTargets;
  52866. /**
  52867. * Gets the list of input points
  52868. */
  52869. readonly inputs: NodeMaterialConnectionPoint[];
  52870. /** Gets the list of output points */
  52871. readonly outputs: NodeMaterialConnectionPoint[];
  52872. /**
  52873. * Find an input by its name
  52874. * @param name defines the name of the input to look for
  52875. * @returns the input or null if not found
  52876. */
  52877. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52878. /**
  52879. * Find an output by its name
  52880. * @param name defines the name of the outputto look for
  52881. * @returns the output or null if not found
  52882. */
  52883. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52884. /**
  52885. * Creates a new NodeMaterialBlock
  52886. * @param name defines the block name
  52887. * @param target defines the target of that block (Vertex by default)
  52888. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52889. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52890. */
  52891. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52892. /**
  52893. * Initialize the block and prepare the context for build
  52894. * @param state defines the state that will be used for the build
  52895. */
  52896. initialize(state: NodeMaterialBuildState): void;
  52897. /**
  52898. * Bind data to effect. Will only be called for blocks with isBindable === true
  52899. * @param effect defines the effect to bind data to
  52900. * @param nodeMaterial defines the hosting NodeMaterial
  52901. * @param mesh defines the mesh that will be rendered
  52902. */
  52903. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52904. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52905. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52906. protected _writeFloat(value: number): string;
  52907. /**
  52908. * Gets the current class name e.g. "NodeMaterialBlock"
  52909. * @returns the class name
  52910. */
  52911. getClassName(): string;
  52912. /**
  52913. * Register a new input. Must be called inside a block constructor
  52914. * @param name defines the connection point name
  52915. * @param type defines the connection point type
  52916. * @param isOptional defines a boolean indicating that this input can be omitted
  52917. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52918. * @returns the current block
  52919. */
  52920. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52921. /**
  52922. * Register a new output. Must be called inside a block constructor
  52923. * @param name defines the connection point name
  52924. * @param type defines the connection point type
  52925. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52926. * @returns the current block
  52927. */
  52928. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52929. /**
  52930. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52931. * @param forOutput defines an optional connection point to check compatibility with
  52932. * @returns the first available input or null
  52933. */
  52934. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52935. /**
  52936. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52937. * @param forBlock defines an optional block to check compatibility with
  52938. * @returns the first available input or null
  52939. */
  52940. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52941. /**
  52942. * Gets the sibling of the given output
  52943. * @param current defines the current output
  52944. * @returns the next output in the list or null
  52945. */
  52946. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52947. /**
  52948. * Connect current block with another block
  52949. * @param other defines the block to connect with
  52950. * @param options define the various options to help pick the right connections
  52951. * @returns the current block
  52952. */
  52953. connectTo(other: NodeMaterialBlock, options?: {
  52954. input?: string;
  52955. output?: string;
  52956. outputSwizzle?: string;
  52957. }): this | undefined;
  52958. protected _buildBlock(state: NodeMaterialBuildState): void;
  52959. /**
  52960. * Add uniforms, samplers and uniform buffers at compilation time
  52961. * @param state defines the state to update
  52962. * @param nodeMaterial defines the node material requesting the update
  52963. * @param defines defines the material defines to update
  52964. */
  52965. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52966. /**
  52967. * Add potential fallbacks if shader compilation fails
  52968. * @param mesh defines the mesh to be rendered
  52969. * @param fallbacks defines the current prioritized list of fallbacks
  52970. */
  52971. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52972. /**
  52973. * Update defines for shader compilation
  52974. * @param mesh defines the mesh to be rendered
  52975. * @param nodeMaterial defines the node material requesting the update
  52976. * @param defines defines the material defines to update
  52977. * @param useInstances specifies that instances should be used
  52978. */
  52979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52980. /**
  52981. * Initialize defines for shader compilation
  52982. * @param mesh defines the mesh to be rendered
  52983. * @param nodeMaterial defines the node material requesting the update
  52984. * @param defines defines the material defines to be prepared
  52985. * @param useInstances specifies that instances should be used
  52986. */
  52987. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52988. /**
  52989. * Lets the block try to connect some inputs automatically
  52990. * @param material defines the hosting NodeMaterial
  52991. */
  52992. autoConfigure(material: NodeMaterial): void;
  52993. /**
  52994. * Function called when a block is declared as repeatable content generator
  52995. * @param vertexShaderState defines the current compilation state for the vertex shader
  52996. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52997. * @param mesh defines the mesh to be rendered
  52998. * @param defines defines the material defines to update
  52999. */
  53000. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53001. /**
  53002. * Checks if the block is ready
  53003. * @param mesh defines the mesh to be rendered
  53004. * @param nodeMaterial defines the node material requesting the update
  53005. * @param defines defines the material defines to update
  53006. * @param useInstances specifies that instances should be used
  53007. * @returns true if the block is ready
  53008. */
  53009. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53010. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53011. private _processBuild;
  53012. /**
  53013. * Compile the current node and generate the shader code
  53014. * @param state defines the current compilation state (uniforms, samplers, current string)
  53015. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53016. * @returns true if already built
  53017. */
  53018. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53019. protected _inputRename(name: string): string;
  53020. protected _outputRename(name: string): string;
  53021. protected _dumpPropertiesCode(): string;
  53022. /** @hidden */
  53023. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53024. /**
  53025. * Clone the current block to a new identical block
  53026. * @param scene defines the hosting scene
  53027. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53028. * @returns a copy of the current block
  53029. */
  53030. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53031. /**
  53032. * Serializes this block in a JSON representation
  53033. * @returns the serialized block object
  53034. */
  53035. serialize(): any;
  53036. /** @hidden */
  53037. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53038. }
  53039. }
  53040. declare module BABYLON {
  53041. /**
  53042. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53043. */
  53044. export enum NodeMaterialBlockConnectionPointMode {
  53045. /** Value is an uniform */
  53046. Uniform = 0,
  53047. /** Value is a mesh attribute */
  53048. Attribute = 1,
  53049. /** Value is a varying between vertex and fragment shaders */
  53050. Varying = 2,
  53051. /** Mode is undefined */
  53052. Undefined = 3
  53053. }
  53054. }
  53055. declare module BABYLON {
  53056. /**
  53057. * Enum defining the type of animations supported by InputBlock
  53058. */
  53059. export enum AnimatedInputBlockTypes {
  53060. /** No animation */
  53061. None = 0,
  53062. /** Time based animation. Will only work for floats */
  53063. Time = 1
  53064. }
  53065. }
  53066. declare module BABYLON {
  53067. /**
  53068. * Block used to expose an input value
  53069. */
  53070. export class InputBlock extends NodeMaterialBlock {
  53071. private _mode;
  53072. private _associatedVariableName;
  53073. private _storedValue;
  53074. private _valueCallback;
  53075. private _type;
  53076. private _animationType;
  53077. /** Gets or set a value used to limit the range of float values */
  53078. min: number;
  53079. /** Gets or set a value used to limit the range of float values */
  53080. max: number;
  53081. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53082. matrixMode: number;
  53083. /** @hidden */
  53084. _systemValue: Nullable<NodeMaterialSystemValues>;
  53085. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53086. visibleInInspector: boolean;
  53087. /**
  53088. * Gets or sets the connection point type (default is float)
  53089. */
  53090. readonly type: NodeMaterialBlockConnectionPointTypes;
  53091. /**
  53092. * Creates a new InputBlock
  53093. * @param name defines the block name
  53094. * @param target defines the target of that block (Vertex by default)
  53095. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53096. */
  53097. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53098. /**
  53099. * Gets the output component
  53100. */
  53101. readonly output: NodeMaterialConnectionPoint;
  53102. /**
  53103. * Set the source of this connection point to a vertex attribute
  53104. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53105. * @returns the current connection point
  53106. */
  53107. setAsAttribute(attributeName?: string): InputBlock;
  53108. /**
  53109. * Set the source of this connection point to a system value
  53110. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53111. * @returns the current connection point
  53112. */
  53113. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53114. /**
  53115. * Gets or sets the value of that point.
  53116. * Please note that this value will be ignored if valueCallback is defined
  53117. */
  53118. value: any;
  53119. /**
  53120. * Gets or sets a callback used to get the value of that point.
  53121. * Please note that setting this value will force the connection point to ignore the value property
  53122. */
  53123. valueCallback: () => any;
  53124. /**
  53125. * Gets or sets the associated variable name in the shader
  53126. */
  53127. associatedVariableName: string;
  53128. /** Gets or sets the type of animation applied to the input */
  53129. animationType: AnimatedInputBlockTypes;
  53130. /**
  53131. * Gets a boolean indicating that this connection point not defined yet
  53132. */
  53133. readonly isUndefined: boolean;
  53134. /**
  53135. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53136. * In this case the connection point name must be the name of the uniform to use.
  53137. * Can only be set on inputs
  53138. */
  53139. isUniform: boolean;
  53140. /**
  53141. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53142. * In this case the connection point name must be the name of the attribute to use
  53143. * Can only be set on inputs
  53144. */
  53145. isAttribute: boolean;
  53146. /**
  53147. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53148. * Can only be set on exit points
  53149. */
  53150. isVarying: boolean;
  53151. /**
  53152. * Gets a boolean indicating that the current connection point is a system value
  53153. */
  53154. readonly isSystemValue: boolean;
  53155. /**
  53156. * Gets or sets the current well known value or null if not defined as a system value
  53157. */
  53158. systemValue: Nullable<NodeMaterialSystemValues>;
  53159. /**
  53160. * Gets the current class name
  53161. * @returns the class name
  53162. */
  53163. getClassName(): string;
  53164. /**
  53165. * Animate the input if animationType !== None
  53166. * @param scene defines the rendering scene
  53167. */
  53168. animate(scene: Scene): void;
  53169. private _emitDefine;
  53170. initialize(state: NodeMaterialBuildState): void;
  53171. /**
  53172. * Set the input block to its default value (based on its type)
  53173. */
  53174. setDefaultValue(): void;
  53175. protected _dumpPropertiesCode(): string;
  53176. private _emit;
  53177. /** @hidden */
  53178. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53179. /** @hidden */
  53180. _transmit(effect: Effect, scene: Scene): void;
  53181. protected _buildBlock(state: NodeMaterialBuildState): void;
  53182. serialize(): any;
  53183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53184. }
  53185. }
  53186. declare module BABYLON {
  53187. /**
  53188. * Defines a connection point for a block
  53189. */
  53190. export class NodeMaterialConnectionPoint {
  53191. /** @hidden */
  53192. _ownerBlock: NodeMaterialBlock;
  53193. /** @hidden */
  53194. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53195. private _endpoints;
  53196. private _associatedVariableName;
  53197. /** @hidden */
  53198. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53199. /** @hidden */
  53200. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53201. private _type;
  53202. /** @hidden */
  53203. _enforceAssociatedVariableName: boolean;
  53204. /**
  53205. * Gets or sets the additional types supported byt this connection point
  53206. */
  53207. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53208. /**
  53209. * Gets or sets the associated variable name in the shader
  53210. */
  53211. associatedVariableName: string;
  53212. /**
  53213. * Gets or sets the connection point type (default is float)
  53214. */
  53215. type: NodeMaterialBlockConnectionPointTypes;
  53216. /**
  53217. * Gets or sets the connection point name
  53218. */
  53219. name: string;
  53220. /**
  53221. * Gets or sets a boolean indicating that this connection point can be omitted
  53222. */
  53223. isOptional: boolean;
  53224. /**
  53225. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53226. */
  53227. define: string;
  53228. /** Gets or sets the target of that connection point */
  53229. target: NodeMaterialBlockTargets;
  53230. /**
  53231. * Gets a boolean indicating that the current point is connected
  53232. */
  53233. readonly isConnected: boolean;
  53234. /**
  53235. * Gets a boolean indicating that the current point is connected to an input block
  53236. */
  53237. readonly isConnectedToInputBlock: boolean;
  53238. /**
  53239. * Gets a the connected input block (if any)
  53240. */
  53241. readonly connectInputBlock: Nullable<InputBlock>;
  53242. /** Get the other side of the connection (if any) */
  53243. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53244. /** Get the block that owns this connection point */
  53245. readonly ownerBlock: NodeMaterialBlock;
  53246. /** Get the block connected on the other side of this connection (if any) */
  53247. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53248. /** Get the block connected on the endpoints of this connection (if any) */
  53249. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53250. /** Gets the list of connected endpoints */
  53251. readonly endpoints: NodeMaterialConnectionPoint[];
  53252. /** Gets a boolean indicating if that output point is connected to at least one input */
  53253. readonly hasEndpoints: boolean;
  53254. /**
  53255. * Creates a new connection point
  53256. * @param name defines the connection point name
  53257. * @param ownerBlock defines the block hosting this connection point
  53258. */
  53259. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53260. /**
  53261. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53262. * @returns the class name
  53263. */
  53264. getClassName(): string;
  53265. /**
  53266. * Gets an boolean indicating if the current point can be connected to another point
  53267. * @param connectionPoint defines the other connection point
  53268. * @returns true if the connection is possible
  53269. */
  53270. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53271. /**
  53272. * Connect this point to another connection point
  53273. * @param connectionPoint defines the other connection point
  53274. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53275. * @returns the current connection point
  53276. */
  53277. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53278. /**
  53279. * Disconnect this point from one of his endpoint
  53280. * @param endpoint defines the other connection point
  53281. * @returns the current connection point
  53282. */
  53283. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53284. /**
  53285. * Serializes this point in a JSON representation
  53286. * @returns the serialized point object
  53287. */
  53288. serialize(): any;
  53289. }
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * Block used to add support for vertex skinning (bones)
  53294. */
  53295. export class BonesBlock extends NodeMaterialBlock {
  53296. /**
  53297. * Creates a new BonesBlock
  53298. * @param name defines the block name
  53299. */
  53300. constructor(name: string);
  53301. /**
  53302. * Initialize the block and prepare the context for build
  53303. * @param state defines the state that will be used for the build
  53304. */
  53305. initialize(state: NodeMaterialBuildState): void;
  53306. /**
  53307. * Gets the current class name
  53308. * @returns the class name
  53309. */
  53310. getClassName(): string;
  53311. /**
  53312. * Gets the matrix indices input component
  53313. */
  53314. readonly matricesIndices: NodeMaterialConnectionPoint;
  53315. /**
  53316. * Gets the matrix weights input component
  53317. */
  53318. readonly matricesWeights: NodeMaterialConnectionPoint;
  53319. /**
  53320. * Gets the extra matrix indices input component
  53321. */
  53322. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53323. /**
  53324. * Gets the extra matrix weights input component
  53325. */
  53326. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53327. /**
  53328. * Gets the world input component
  53329. */
  53330. readonly world: NodeMaterialConnectionPoint;
  53331. /**
  53332. * Gets the output component
  53333. */
  53334. readonly output: NodeMaterialConnectionPoint;
  53335. autoConfigure(material: NodeMaterial): void;
  53336. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53339. protected _buildBlock(state: NodeMaterialBuildState): this;
  53340. }
  53341. }
  53342. declare module BABYLON {
  53343. /**
  53344. * Block used to add support for instances
  53345. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53346. */
  53347. export class InstancesBlock extends NodeMaterialBlock {
  53348. /**
  53349. * Creates a new InstancesBlock
  53350. * @param name defines the block name
  53351. */
  53352. constructor(name: string);
  53353. /**
  53354. * Gets the current class name
  53355. * @returns the class name
  53356. */
  53357. getClassName(): string;
  53358. /**
  53359. * Gets the first world row input component
  53360. */
  53361. readonly world0: NodeMaterialConnectionPoint;
  53362. /**
  53363. * Gets the second world row input component
  53364. */
  53365. readonly world1: NodeMaterialConnectionPoint;
  53366. /**
  53367. * Gets the third world row input component
  53368. */
  53369. readonly world2: NodeMaterialConnectionPoint;
  53370. /**
  53371. * Gets the forth world row input component
  53372. */
  53373. readonly world3: NodeMaterialConnectionPoint;
  53374. /**
  53375. * Gets the world input component
  53376. */
  53377. readonly world: NodeMaterialConnectionPoint;
  53378. /**
  53379. * Gets the output component
  53380. */
  53381. readonly output: NodeMaterialConnectionPoint;
  53382. autoConfigure(material: NodeMaterial): void;
  53383. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53384. protected _buildBlock(state: NodeMaterialBuildState): this;
  53385. }
  53386. }
  53387. declare module BABYLON {
  53388. /**
  53389. * Block used to add morph targets support to vertex shader
  53390. */
  53391. export class MorphTargetsBlock extends NodeMaterialBlock {
  53392. private _repeatableContentAnchor;
  53393. private _repeatebleContentGenerated;
  53394. /**
  53395. * Create a new MorphTargetsBlock
  53396. * @param name defines the block name
  53397. */
  53398. constructor(name: string);
  53399. /**
  53400. * Gets the current class name
  53401. * @returns the class name
  53402. */
  53403. getClassName(): string;
  53404. /**
  53405. * Gets the position input component
  53406. */
  53407. readonly position: NodeMaterialConnectionPoint;
  53408. /**
  53409. * Gets the normal input component
  53410. */
  53411. readonly normal: NodeMaterialConnectionPoint;
  53412. /**
  53413. * Gets the tangent input component
  53414. */
  53415. readonly tangent: NodeMaterialConnectionPoint;
  53416. /**
  53417. * Gets the tangent input component
  53418. */
  53419. readonly uv: NodeMaterialConnectionPoint;
  53420. /**
  53421. * Gets the position output component
  53422. */
  53423. readonly positionOutput: NodeMaterialConnectionPoint;
  53424. /**
  53425. * Gets the normal output component
  53426. */
  53427. readonly normalOutput: NodeMaterialConnectionPoint;
  53428. /**
  53429. * Gets the tangent output component
  53430. */
  53431. readonly tangentOutput: NodeMaterialConnectionPoint;
  53432. /**
  53433. * Gets the tangent output component
  53434. */
  53435. readonly uvOutput: NodeMaterialConnectionPoint;
  53436. initialize(state: NodeMaterialBuildState): void;
  53437. autoConfigure(material: NodeMaterial): void;
  53438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53440. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53441. protected _buildBlock(state: NodeMaterialBuildState): this;
  53442. }
  53443. }
  53444. declare module BABYLON {
  53445. /**
  53446. * Block used to get data information from a light
  53447. */
  53448. export class LightInformationBlock extends NodeMaterialBlock {
  53449. private _lightDataDefineName;
  53450. private _lightColorDefineName;
  53451. /**
  53452. * Gets or sets the light associated with this block
  53453. */
  53454. light: Nullable<Light>;
  53455. /**
  53456. * Creates a new LightInformationBlock
  53457. * @param name defines the block name
  53458. */
  53459. constructor(name: string);
  53460. /**
  53461. * Gets the current class name
  53462. * @returns the class name
  53463. */
  53464. getClassName(): string;
  53465. /**
  53466. * Gets the world position input component
  53467. */
  53468. readonly worldPosition: NodeMaterialConnectionPoint;
  53469. /**
  53470. * Gets the direction output component
  53471. */
  53472. readonly direction: NodeMaterialConnectionPoint;
  53473. /**
  53474. * Gets the direction output component
  53475. */
  53476. readonly color: NodeMaterialConnectionPoint;
  53477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53478. protected _buildBlock(state: NodeMaterialBuildState): this;
  53479. serialize(): any;
  53480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53481. }
  53482. }
  53483. declare module BABYLON {
  53484. /**
  53485. * Block used to add an alpha test in the fragment shader
  53486. */
  53487. export class AlphaTestBlock extends NodeMaterialBlock {
  53488. /**
  53489. * Gets or sets the alpha value where alpha testing happens
  53490. */
  53491. alphaCutOff: number;
  53492. /**
  53493. * Create a new AlphaTestBlock
  53494. * @param name defines the block name
  53495. */
  53496. constructor(name: string);
  53497. /**
  53498. * Gets the current class name
  53499. * @returns the class name
  53500. */
  53501. getClassName(): string;
  53502. /**
  53503. * Gets the color input component
  53504. */
  53505. readonly color: NodeMaterialConnectionPoint;
  53506. /**
  53507. * Gets the alpha input component
  53508. */
  53509. readonly alpha: NodeMaterialConnectionPoint;
  53510. protected _buildBlock(state: NodeMaterialBuildState): this;
  53511. protected _dumpPropertiesCode(): string;
  53512. serialize(): any;
  53513. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53514. }
  53515. }
  53516. declare module BABYLON {
  53517. /**
  53518. * Block used to add image processing support to fragment shader
  53519. */
  53520. export class ImageProcessingBlock extends NodeMaterialBlock {
  53521. /**
  53522. * Create a new ImageProcessingBlock
  53523. * @param name defines the block name
  53524. */
  53525. constructor(name: string);
  53526. /**
  53527. * Gets the current class name
  53528. * @returns the class name
  53529. */
  53530. getClassName(): string;
  53531. /**
  53532. * Gets the color input component
  53533. */
  53534. readonly color: NodeMaterialConnectionPoint;
  53535. /**
  53536. * Gets the output component
  53537. */
  53538. readonly output: NodeMaterialConnectionPoint;
  53539. /**
  53540. * Initialize the block and prepare the context for build
  53541. * @param state defines the state that will be used for the build
  53542. */
  53543. initialize(state: NodeMaterialBuildState): void;
  53544. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53547. protected _buildBlock(state: NodeMaterialBuildState): this;
  53548. }
  53549. }
  53550. declare module BABYLON {
  53551. /**
  53552. * Block used to pertub normals based on a normal map
  53553. */
  53554. export class PerturbNormalBlock extends NodeMaterialBlock {
  53555. private _tangentSpaceParameterName;
  53556. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53557. invertX: boolean;
  53558. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53559. invertY: boolean;
  53560. /**
  53561. * Create a new PerturbNormalBlock
  53562. * @param name defines the block name
  53563. */
  53564. constructor(name: string);
  53565. /**
  53566. * Gets the current class name
  53567. * @returns the class name
  53568. */
  53569. getClassName(): string;
  53570. /**
  53571. * Gets the world position input component
  53572. */
  53573. readonly worldPosition: NodeMaterialConnectionPoint;
  53574. /**
  53575. * Gets the world normal input component
  53576. */
  53577. readonly worldNormal: NodeMaterialConnectionPoint;
  53578. /**
  53579. * Gets the uv input component
  53580. */
  53581. readonly uv: NodeMaterialConnectionPoint;
  53582. /**
  53583. * Gets the normal map color input component
  53584. */
  53585. readonly normalMapColor: NodeMaterialConnectionPoint;
  53586. /**
  53587. * Gets the strength input component
  53588. */
  53589. readonly strength: NodeMaterialConnectionPoint;
  53590. /**
  53591. * Gets the output component
  53592. */
  53593. readonly output: NodeMaterialConnectionPoint;
  53594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53595. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53596. autoConfigure(material: NodeMaterial): void;
  53597. protected _buildBlock(state: NodeMaterialBuildState): this;
  53598. protected _dumpPropertiesCode(): string;
  53599. serialize(): any;
  53600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53601. }
  53602. }
  53603. declare module BABYLON {
  53604. /**
  53605. * Block used to add support for scene fog
  53606. */
  53607. export class FogBlock extends NodeMaterialBlock {
  53608. private _fogDistanceName;
  53609. private _fogParameters;
  53610. /**
  53611. * Create a new FogBlock
  53612. * @param name defines the block name
  53613. */
  53614. constructor(name: string);
  53615. /**
  53616. * Gets the current class name
  53617. * @returns the class name
  53618. */
  53619. getClassName(): string;
  53620. /**
  53621. * Gets the world position input component
  53622. */
  53623. readonly worldPosition: NodeMaterialConnectionPoint;
  53624. /**
  53625. * Gets the view input component
  53626. */
  53627. readonly view: NodeMaterialConnectionPoint;
  53628. /**
  53629. * Gets the color input component
  53630. */
  53631. readonly input: NodeMaterialConnectionPoint;
  53632. /**
  53633. * Gets the fog color input component
  53634. */
  53635. readonly fogColor: NodeMaterialConnectionPoint;
  53636. /**
  53637. * Gets the output component
  53638. */
  53639. readonly output: NodeMaterialConnectionPoint;
  53640. autoConfigure(material: NodeMaterial): void;
  53641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53643. protected _buildBlock(state: NodeMaterialBuildState): this;
  53644. }
  53645. }
  53646. declare module BABYLON {
  53647. /**
  53648. * Block used to add light in the fragment shader
  53649. */
  53650. export class LightBlock extends NodeMaterialBlock {
  53651. private _lightId;
  53652. /**
  53653. * Gets or sets the light associated with this block
  53654. */
  53655. light: Nullable<Light>;
  53656. /**
  53657. * Create a new LightBlock
  53658. * @param name defines the block name
  53659. */
  53660. constructor(name: string);
  53661. /**
  53662. * Gets the current class name
  53663. * @returns the class name
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Gets the world position input component
  53668. */
  53669. readonly worldPosition: NodeMaterialConnectionPoint;
  53670. /**
  53671. * Gets the world normal input component
  53672. */
  53673. readonly worldNormal: NodeMaterialConnectionPoint;
  53674. /**
  53675. * Gets the camera (or eye) position component
  53676. */
  53677. readonly cameraPosition: NodeMaterialConnectionPoint;
  53678. /**
  53679. * Gets the diffuse output component
  53680. */
  53681. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53682. /**
  53683. * Gets the specular output component
  53684. */
  53685. readonly specularOutput: NodeMaterialConnectionPoint;
  53686. autoConfigure(material: NodeMaterial): void;
  53687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53688. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53689. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53690. private _injectVertexCode;
  53691. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53692. serialize(): any;
  53693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53694. }
  53695. }
  53696. declare module BABYLON {
  53697. /**
  53698. * Block used to multiply 2 values
  53699. */
  53700. export class MultiplyBlock extends NodeMaterialBlock {
  53701. /**
  53702. * Creates a new MultiplyBlock
  53703. * @param name defines the block name
  53704. */
  53705. constructor(name: string);
  53706. /**
  53707. * Gets the current class name
  53708. * @returns the class name
  53709. */
  53710. getClassName(): string;
  53711. /**
  53712. * Gets the left operand input component
  53713. */
  53714. readonly left: NodeMaterialConnectionPoint;
  53715. /**
  53716. * Gets the right operand input component
  53717. */
  53718. readonly right: NodeMaterialConnectionPoint;
  53719. /**
  53720. * Gets the output component
  53721. */
  53722. readonly output: NodeMaterialConnectionPoint;
  53723. protected _buildBlock(state: NodeMaterialBuildState): this;
  53724. }
  53725. }
  53726. declare module BABYLON {
  53727. /**
  53728. * Block used to add 2 vectors
  53729. */
  53730. export class AddBlock extends NodeMaterialBlock {
  53731. /**
  53732. * Creates a new AddBlock
  53733. * @param name defines the block name
  53734. */
  53735. constructor(name: string);
  53736. /**
  53737. * Gets the current class name
  53738. * @returns the class name
  53739. */
  53740. getClassName(): string;
  53741. /**
  53742. * Gets the left operand input component
  53743. */
  53744. readonly left: NodeMaterialConnectionPoint;
  53745. /**
  53746. * Gets the right operand input component
  53747. */
  53748. readonly right: NodeMaterialConnectionPoint;
  53749. /**
  53750. * Gets the output component
  53751. */
  53752. readonly output: NodeMaterialConnectionPoint;
  53753. protected _buildBlock(state: NodeMaterialBuildState): this;
  53754. }
  53755. }
  53756. declare module BABYLON {
  53757. /**
  53758. * Block used to scale a vector by a float
  53759. */
  53760. export class ScaleBlock extends NodeMaterialBlock {
  53761. /**
  53762. * Creates a new ScaleBlock
  53763. * @param name defines the block name
  53764. */
  53765. constructor(name: string);
  53766. /**
  53767. * Gets the current class name
  53768. * @returns the class name
  53769. */
  53770. getClassName(): string;
  53771. /**
  53772. * Gets the input component
  53773. */
  53774. readonly input: NodeMaterialConnectionPoint;
  53775. /**
  53776. * Gets the factor input component
  53777. */
  53778. readonly factor: NodeMaterialConnectionPoint;
  53779. /**
  53780. * Gets the output component
  53781. */
  53782. readonly output: NodeMaterialConnectionPoint;
  53783. protected _buildBlock(state: NodeMaterialBuildState): this;
  53784. }
  53785. }
  53786. declare module BABYLON {
  53787. /**
  53788. * Block used to clamp a float
  53789. */
  53790. export class ClampBlock extends NodeMaterialBlock {
  53791. /** Gets or sets the minimum range */
  53792. minimum: number;
  53793. /** Gets or sets the maximum range */
  53794. maximum: number;
  53795. /**
  53796. * Creates a new ClampBlock
  53797. * @param name defines the block name
  53798. */
  53799. constructor(name: string);
  53800. /**
  53801. * Gets the current class name
  53802. * @returns the class name
  53803. */
  53804. getClassName(): string;
  53805. /**
  53806. * Gets the value input component
  53807. */
  53808. readonly value: NodeMaterialConnectionPoint;
  53809. /**
  53810. * Gets the output component
  53811. */
  53812. readonly output: NodeMaterialConnectionPoint;
  53813. protected _buildBlock(state: NodeMaterialBuildState): this;
  53814. protected _dumpPropertiesCode(): string;
  53815. serialize(): any;
  53816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53817. }
  53818. }
  53819. declare module BABYLON {
  53820. /**
  53821. * Block used to apply a cross product between 2 vectors
  53822. */
  53823. export class CrossBlock extends NodeMaterialBlock {
  53824. /**
  53825. * Creates a new CrossBlock
  53826. * @param name defines the block name
  53827. */
  53828. constructor(name: string);
  53829. /**
  53830. * Gets the current class name
  53831. * @returns the class name
  53832. */
  53833. getClassName(): string;
  53834. /**
  53835. * Gets the left operand input component
  53836. */
  53837. readonly left: NodeMaterialConnectionPoint;
  53838. /**
  53839. * Gets the right operand input component
  53840. */
  53841. readonly right: NodeMaterialConnectionPoint;
  53842. /**
  53843. * Gets the output component
  53844. */
  53845. readonly output: NodeMaterialConnectionPoint;
  53846. protected _buildBlock(state: NodeMaterialBuildState): this;
  53847. }
  53848. }
  53849. declare module BABYLON {
  53850. /**
  53851. * Block used to apply a dot product between 2 vectors
  53852. */
  53853. export class DotBlock extends NodeMaterialBlock {
  53854. /**
  53855. * Creates a new DotBlock
  53856. * @param name defines the block name
  53857. */
  53858. constructor(name: string);
  53859. /**
  53860. * Gets the current class name
  53861. * @returns the class name
  53862. */
  53863. getClassName(): string;
  53864. /**
  53865. * Gets the left operand input component
  53866. */
  53867. readonly left: NodeMaterialConnectionPoint;
  53868. /**
  53869. * Gets the right operand input component
  53870. */
  53871. readonly right: NodeMaterialConnectionPoint;
  53872. /**
  53873. * Gets the output component
  53874. */
  53875. readonly output: NodeMaterialConnectionPoint;
  53876. protected _buildBlock(state: NodeMaterialBuildState): this;
  53877. }
  53878. }
  53879. declare module BABYLON {
  53880. /**
  53881. * Block used to remap a float from a range to a new one
  53882. */
  53883. export class RemapBlock extends NodeMaterialBlock {
  53884. /**
  53885. * Gets or sets the source range
  53886. */
  53887. sourceRange: Vector2;
  53888. /**
  53889. * Gets or sets the target range
  53890. */
  53891. targetRange: Vector2;
  53892. /**
  53893. * Creates a new RemapBlock
  53894. * @param name defines the block name
  53895. */
  53896. constructor(name: string);
  53897. /**
  53898. * Gets the current class name
  53899. * @returns the class name
  53900. */
  53901. getClassName(): string;
  53902. /**
  53903. * Gets the input component
  53904. */
  53905. readonly input: NodeMaterialConnectionPoint;
  53906. /**
  53907. * Gets the source min input component
  53908. */
  53909. readonly sourceMin: NodeMaterialConnectionPoint;
  53910. /**
  53911. * Gets the source max input component
  53912. */
  53913. readonly sourceMax: NodeMaterialConnectionPoint;
  53914. /**
  53915. * Gets the target min input component
  53916. */
  53917. readonly targetMin: NodeMaterialConnectionPoint;
  53918. /**
  53919. * Gets the target max input component
  53920. */
  53921. readonly targetMax: NodeMaterialConnectionPoint;
  53922. /**
  53923. * Gets the output component
  53924. */
  53925. readonly output: NodeMaterialConnectionPoint;
  53926. protected _buildBlock(state: NodeMaterialBuildState): this;
  53927. protected _dumpPropertiesCode(): string;
  53928. serialize(): any;
  53929. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53930. }
  53931. }
  53932. declare module BABYLON {
  53933. /**
  53934. * Block used to normalize a vector
  53935. */
  53936. export class NormalizeBlock extends NodeMaterialBlock {
  53937. /**
  53938. * Creates a new NormalizeBlock
  53939. * @param name defines the block name
  53940. */
  53941. constructor(name: string);
  53942. /**
  53943. * Gets the current class name
  53944. * @returns the class name
  53945. */
  53946. getClassName(): string;
  53947. /**
  53948. * Gets the input component
  53949. */
  53950. readonly input: NodeMaterialConnectionPoint;
  53951. /**
  53952. * Gets the output component
  53953. */
  53954. readonly output: NodeMaterialConnectionPoint;
  53955. protected _buildBlock(state: NodeMaterialBuildState): this;
  53956. }
  53957. }
  53958. declare module BABYLON {
  53959. /**
  53960. * Operations supported by the Trigonometry block
  53961. */
  53962. export enum TrigonometryBlockOperations {
  53963. /** Cos */
  53964. Cos = 0,
  53965. /** Sin */
  53966. Sin = 1,
  53967. /** Abs */
  53968. Abs = 2,
  53969. /** Exp */
  53970. Exp = 3,
  53971. /** Exp2 */
  53972. Exp2 = 4,
  53973. /** Round */
  53974. Round = 5,
  53975. /** Floor */
  53976. Floor = 6,
  53977. /** Ceiling */
  53978. Ceiling = 7
  53979. }
  53980. /**
  53981. * Block used to apply trigonometry operation to floats
  53982. */
  53983. export class TrigonometryBlock extends NodeMaterialBlock {
  53984. /**
  53985. * Gets or sets the operation applied by the block
  53986. */
  53987. operation: TrigonometryBlockOperations;
  53988. /**
  53989. * Creates a new TrigonometryBlock
  53990. * @param name defines the block name
  53991. */
  53992. constructor(name: string);
  53993. /**
  53994. * Gets the current class name
  53995. * @returns the class name
  53996. */
  53997. getClassName(): string;
  53998. /**
  53999. * Gets the input component
  54000. */
  54001. readonly input: NodeMaterialConnectionPoint;
  54002. /**
  54003. * Gets the output component
  54004. */
  54005. readonly output: NodeMaterialConnectionPoint;
  54006. protected _buildBlock(state: NodeMaterialBuildState): this;
  54007. serialize(): any;
  54008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54009. }
  54010. }
  54011. declare module BABYLON {
  54012. /**
  54013. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54014. */
  54015. export class ColorMergerBlock extends NodeMaterialBlock {
  54016. /**
  54017. * Create a new ColorMergerBlock
  54018. * @param name defines the block name
  54019. */
  54020. constructor(name: string);
  54021. /**
  54022. * Gets the current class name
  54023. * @returns the class name
  54024. */
  54025. getClassName(): string;
  54026. /**
  54027. * Gets the r component (input)
  54028. */
  54029. readonly r: NodeMaterialConnectionPoint;
  54030. /**
  54031. * Gets the g component (input)
  54032. */
  54033. readonly g: NodeMaterialConnectionPoint;
  54034. /**
  54035. * Gets the b component (input)
  54036. */
  54037. readonly b: NodeMaterialConnectionPoint;
  54038. /**
  54039. * Gets the a component (input)
  54040. */
  54041. readonly a: NodeMaterialConnectionPoint;
  54042. /**
  54043. * Gets the rgba component (output)
  54044. */
  54045. readonly rgba: NodeMaterialConnectionPoint;
  54046. /**
  54047. * Gets the rgb component (output)
  54048. */
  54049. readonly rgb: NodeMaterialConnectionPoint;
  54050. protected _buildBlock(state: NodeMaterialBuildState): this;
  54051. }
  54052. }
  54053. declare module BABYLON {
  54054. /**
  54055. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54056. */
  54057. export class VectorMergerBlock extends NodeMaterialBlock {
  54058. /**
  54059. * Create a new VectorMergerBlock
  54060. * @param name defines the block name
  54061. */
  54062. constructor(name: string);
  54063. /**
  54064. * Gets the current class name
  54065. * @returns the class name
  54066. */
  54067. getClassName(): string;
  54068. /**
  54069. * Gets the x component (input)
  54070. */
  54071. readonly x: NodeMaterialConnectionPoint;
  54072. /**
  54073. * Gets the y component (input)
  54074. */
  54075. readonly y: NodeMaterialConnectionPoint;
  54076. /**
  54077. * Gets the z component (input)
  54078. */
  54079. readonly z: NodeMaterialConnectionPoint;
  54080. /**
  54081. * Gets the w component (input)
  54082. */
  54083. readonly w: NodeMaterialConnectionPoint;
  54084. /**
  54085. * Gets the xyzw component (output)
  54086. */
  54087. readonly xyzw: NodeMaterialConnectionPoint;
  54088. /**
  54089. * Gets the xyz component (output)
  54090. */
  54091. readonly xyz: NodeMaterialConnectionPoint;
  54092. /**
  54093. * Gets the xy component (output)
  54094. */
  54095. readonly xy: NodeMaterialConnectionPoint;
  54096. protected _buildBlock(state: NodeMaterialBuildState): this;
  54097. }
  54098. }
  54099. declare module BABYLON {
  54100. /**
  54101. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54102. */
  54103. export class ColorSplitterBlock extends NodeMaterialBlock {
  54104. /**
  54105. * Create a new ColorSplitterBlock
  54106. * @param name defines the block name
  54107. */
  54108. constructor(name: string);
  54109. /**
  54110. * Gets the current class name
  54111. * @returns the class name
  54112. */
  54113. getClassName(): string;
  54114. /**
  54115. * Gets the rgba component (input)
  54116. */
  54117. readonly rgba: NodeMaterialConnectionPoint;
  54118. /**
  54119. * Gets the rgb component (input)
  54120. */
  54121. readonly rgbIn: NodeMaterialConnectionPoint;
  54122. /**
  54123. * Gets the rgb component (output)
  54124. */
  54125. readonly rgbOut: NodeMaterialConnectionPoint;
  54126. /**
  54127. * Gets the r component (output)
  54128. */
  54129. readonly r: NodeMaterialConnectionPoint;
  54130. /**
  54131. * Gets the g component (output)
  54132. */
  54133. readonly g: NodeMaterialConnectionPoint;
  54134. /**
  54135. * Gets the b component (output)
  54136. */
  54137. readonly b: NodeMaterialConnectionPoint;
  54138. /**
  54139. * Gets the a component (output)
  54140. */
  54141. readonly a: NodeMaterialConnectionPoint;
  54142. protected _inputRename(name: string): string;
  54143. protected _outputRename(name: string): string;
  54144. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54145. }
  54146. }
  54147. declare module BABYLON {
  54148. /**
  54149. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54150. */
  54151. export class VectorSplitterBlock extends NodeMaterialBlock {
  54152. /**
  54153. * Create a new VectorSplitterBlock
  54154. * @param name defines the block name
  54155. */
  54156. constructor(name: string);
  54157. /**
  54158. * Gets the current class name
  54159. * @returns the class name
  54160. */
  54161. getClassName(): string;
  54162. /**
  54163. * Gets the xyzw component (input)
  54164. */
  54165. readonly xyzw: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the xyz component (input)
  54168. */
  54169. readonly xyzIn: NodeMaterialConnectionPoint;
  54170. /**
  54171. * Gets the xy component (input)
  54172. */
  54173. readonly xyIn: NodeMaterialConnectionPoint;
  54174. /**
  54175. * Gets the xyz component (output)
  54176. */
  54177. readonly xyzOut: NodeMaterialConnectionPoint;
  54178. /**
  54179. * Gets the xy component (output)
  54180. */
  54181. readonly xyOut: NodeMaterialConnectionPoint;
  54182. /**
  54183. * Gets the x component (output)
  54184. */
  54185. readonly x: NodeMaterialConnectionPoint;
  54186. /**
  54187. * Gets the y component (output)
  54188. */
  54189. readonly y: NodeMaterialConnectionPoint;
  54190. /**
  54191. * Gets the z component (output)
  54192. */
  54193. readonly z: NodeMaterialConnectionPoint;
  54194. /**
  54195. * Gets the w component (output)
  54196. */
  54197. readonly w: NodeMaterialConnectionPoint;
  54198. protected _inputRename(name: string): string;
  54199. protected _outputRename(name: string): string;
  54200. protected _buildBlock(state: NodeMaterialBuildState): this;
  54201. }
  54202. }
  54203. declare module BABYLON {
  54204. /**
  54205. * Block used to lerp 2 values
  54206. */
  54207. export class LerpBlock extends NodeMaterialBlock {
  54208. /**
  54209. * Creates a new LerpBlock
  54210. * @param name defines the block name
  54211. */
  54212. constructor(name: string);
  54213. /**
  54214. * Gets the current class name
  54215. * @returns the class name
  54216. */
  54217. getClassName(): string;
  54218. /**
  54219. * Gets the left operand input component
  54220. */
  54221. readonly left: NodeMaterialConnectionPoint;
  54222. /**
  54223. * Gets the right operand input component
  54224. */
  54225. readonly right: NodeMaterialConnectionPoint;
  54226. /**
  54227. * Gets the gradient operand input component
  54228. */
  54229. readonly gradient: NodeMaterialConnectionPoint;
  54230. /**
  54231. * Gets the output component
  54232. */
  54233. readonly output: NodeMaterialConnectionPoint;
  54234. protected _buildBlock(state: NodeMaterialBuildState): this;
  54235. }
  54236. }
  54237. declare module BABYLON {
  54238. /**
  54239. * Block used to divide 2 vectors
  54240. */
  54241. export class DivideBlock extends NodeMaterialBlock {
  54242. /**
  54243. * Creates a new DivideBlock
  54244. * @param name defines the block name
  54245. */
  54246. constructor(name: string);
  54247. /**
  54248. * Gets the current class name
  54249. * @returns the class name
  54250. */
  54251. getClassName(): string;
  54252. /**
  54253. * Gets the left operand input component
  54254. */
  54255. readonly left: NodeMaterialConnectionPoint;
  54256. /**
  54257. * Gets the right operand input component
  54258. */
  54259. readonly right: NodeMaterialConnectionPoint;
  54260. /**
  54261. * Gets the output component
  54262. */
  54263. readonly output: NodeMaterialConnectionPoint;
  54264. protected _buildBlock(state: NodeMaterialBuildState): this;
  54265. }
  54266. }
  54267. declare module BABYLON {
  54268. /**
  54269. * Block used to subtract 2 vectors
  54270. */
  54271. export class SubtractBlock extends NodeMaterialBlock {
  54272. /**
  54273. * Creates a new SubtractBlock
  54274. * @param name defines the block name
  54275. */
  54276. constructor(name: string);
  54277. /**
  54278. * Gets the current class name
  54279. * @returns the class name
  54280. */
  54281. getClassName(): string;
  54282. /**
  54283. * Gets the left operand input component
  54284. */
  54285. readonly left: NodeMaterialConnectionPoint;
  54286. /**
  54287. * Gets the right operand input component
  54288. */
  54289. readonly right: NodeMaterialConnectionPoint;
  54290. /**
  54291. * Gets the output component
  54292. */
  54293. readonly output: NodeMaterialConnectionPoint;
  54294. protected _buildBlock(state: NodeMaterialBuildState): this;
  54295. }
  54296. }
  54297. declare module BABYLON {
  54298. /**
  54299. * Block used to step a value
  54300. */
  54301. export class StepBlock extends NodeMaterialBlock {
  54302. /**
  54303. * Creates a new AddBlock
  54304. * @param name defines the block name
  54305. */
  54306. constructor(name: string);
  54307. /**
  54308. * Gets the current class name
  54309. * @returns the class name
  54310. */
  54311. getClassName(): string;
  54312. /**
  54313. * Gets the value operand input component
  54314. */
  54315. readonly value: NodeMaterialConnectionPoint;
  54316. /**
  54317. * Gets the edge operand input component
  54318. */
  54319. readonly edge: NodeMaterialConnectionPoint;
  54320. /**
  54321. * Gets the output component
  54322. */
  54323. readonly output: NodeMaterialConnectionPoint;
  54324. protected _buildBlock(state: NodeMaterialBuildState): this;
  54325. }
  54326. }
  54327. declare module BABYLON {
  54328. /**
  54329. * Block used to get the opposite (1 - x) of a value
  54330. */
  54331. export class OneMinusBlock extends NodeMaterialBlock {
  54332. /**
  54333. * Creates a new OneMinusBlock
  54334. * @param name defines the block name
  54335. */
  54336. constructor(name: string);
  54337. /**
  54338. * Gets the current class name
  54339. * @returns the class name
  54340. */
  54341. getClassName(): string;
  54342. /**
  54343. * Gets the input component
  54344. */
  54345. readonly input: NodeMaterialConnectionPoint;
  54346. /**
  54347. * Gets the output component
  54348. */
  54349. readonly output: NodeMaterialConnectionPoint;
  54350. protected _buildBlock(state: NodeMaterialBuildState): this;
  54351. }
  54352. }
  54353. declare module BABYLON {
  54354. /**
  54355. * Block used to get the view direction
  54356. */
  54357. export class ViewDirectionBlock extends NodeMaterialBlock {
  54358. /**
  54359. * Creates a new ViewDirectionBlock
  54360. * @param name defines the block name
  54361. */
  54362. constructor(name: string);
  54363. /**
  54364. * Gets the current class name
  54365. * @returns the class name
  54366. */
  54367. getClassName(): string;
  54368. /**
  54369. * Gets the world position component
  54370. */
  54371. readonly worldPosition: NodeMaterialConnectionPoint;
  54372. /**
  54373. * Gets the camera position component
  54374. */
  54375. readonly cameraPosition: NodeMaterialConnectionPoint;
  54376. /**
  54377. * Gets the output component
  54378. */
  54379. readonly output: NodeMaterialConnectionPoint;
  54380. autoConfigure(material: NodeMaterial): void;
  54381. protected _buildBlock(state: NodeMaterialBuildState): this;
  54382. }
  54383. }
  54384. declare module BABYLON {
  54385. /**
  54386. * Block used to compute fresnel value
  54387. */
  54388. export class FresnelBlock extends NodeMaterialBlock {
  54389. /**
  54390. * Create a new FresnelBlock
  54391. * @param name defines the block name
  54392. */
  54393. constructor(name: string);
  54394. /**
  54395. * Gets the current class name
  54396. * @returns the class name
  54397. */
  54398. getClassName(): string;
  54399. /**
  54400. * Gets the world normal input component
  54401. */
  54402. readonly worldNormal: NodeMaterialConnectionPoint;
  54403. /**
  54404. * Gets the view direction input component
  54405. */
  54406. readonly viewDirection: NodeMaterialConnectionPoint;
  54407. /**
  54408. * Gets the bias input component
  54409. */
  54410. readonly bias: NodeMaterialConnectionPoint;
  54411. /**
  54412. * Gets the camera (or eye) position component
  54413. */
  54414. readonly power: NodeMaterialConnectionPoint;
  54415. /**
  54416. * Gets the fresnel output component
  54417. */
  54418. readonly fresnel: NodeMaterialConnectionPoint;
  54419. autoConfigure(material: NodeMaterial): void;
  54420. protected _buildBlock(state: NodeMaterialBuildState): this;
  54421. }
  54422. }
  54423. declare module BABYLON {
  54424. /**
  54425. * Block used to get the max of 2 values
  54426. */
  54427. export class MaxBlock extends NodeMaterialBlock {
  54428. /**
  54429. * Creates a new MaxBlock
  54430. * @param name defines the block name
  54431. */
  54432. constructor(name: string);
  54433. /**
  54434. * Gets the current class name
  54435. * @returns the class name
  54436. */
  54437. getClassName(): string;
  54438. /**
  54439. * Gets the left operand input component
  54440. */
  54441. readonly left: NodeMaterialConnectionPoint;
  54442. /**
  54443. * Gets the right operand input component
  54444. */
  54445. readonly right: NodeMaterialConnectionPoint;
  54446. /**
  54447. * Gets the output component
  54448. */
  54449. readonly output: NodeMaterialConnectionPoint;
  54450. protected _buildBlock(state: NodeMaterialBuildState): this;
  54451. }
  54452. }
  54453. declare module BABYLON {
  54454. /**
  54455. * Block used to get the min of 2 values
  54456. */
  54457. export class MinBlock extends NodeMaterialBlock {
  54458. /**
  54459. * Creates a new MinBlock
  54460. * @param name defines the block name
  54461. */
  54462. constructor(name: string);
  54463. /**
  54464. * Gets the current class name
  54465. * @returns the class name
  54466. */
  54467. getClassName(): string;
  54468. /**
  54469. * Gets the left operand input component
  54470. */
  54471. readonly left: NodeMaterialConnectionPoint;
  54472. /**
  54473. * Gets the right operand input component
  54474. */
  54475. readonly right: NodeMaterialConnectionPoint;
  54476. /**
  54477. * Gets the output component
  54478. */
  54479. readonly output: NodeMaterialConnectionPoint;
  54480. protected _buildBlock(state: NodeMaterialBuildState): this;
  54481. }
  54482. }
  54483. declare module BABYLON {
  54484. /**
  54485. * Block used to get the distance between 2 values
  54486. */
  54487. export class DistanceBlock extends NodeMaterialBlock {
  54488. /**
  54489. * Creates a new DistanceBlock
  54490. * @param name defines the block name
  54491. */
  54492. constructor(name: string);
  54493. /**
  54494. * Gets the current class name
  54495. * @returns the class name
  54496. */
  54497. getClassName(): string;
  54498. /**
  54499. * Gets the left operand input component
  54500. */
  54501. readonly left: NodeMaterialConnectionPoint;
  54502. /**
  54503. * Gets the right operand input component
  54504. */
  54505. readonly right: NodeMaterialConnectionPoint;
  54506. /**
  54507. * Gets the output component
  54508. */
  54509. readonly output: NodeMaterialConnectionPoint;
  54510. protected _buildBlock(state: NodeMaterialBuildState): this;
  54511. }
  54512. }
  54513. declare module BABYLON {
  54514. /**
  54515. * Block used to get the length of a vector
  54516. */
  54517. export class LengthBlock extends NodeMaterialBlock {
  54518. /**
  54519. * Creates a new LengthBlock
  54520. * @param name defines the block name
  54521. */
  54522. constructor(name: string);
  54523. /**
  54524. * Gets the current class name
  54525. * @returns the class name
  54526. */
  54527. getClassName(): string;
  54528. /**
  54529. * Gets the value input component
  54530. */
  54531. readonly value: NodeMaterialConnectionPoint;
  54532. /**
  54533. * Gets the output component
  54534. */
  54535. readonly output: NodeMaterialConnectionPoint;
  54536. protected _buildBlock(state: NodeMaterialBuildState): this;
  54537. }
  54538. }
  54539. declare module BABYLON {
  54540. /**
  54541. * Block used to get negative version of a value (i.e. x * -1)
  54542. */
  54543. export class NegateBlock extends NodeMaterialBlock {
  54544. /**
  54545. * Creates a new NegateBlock
  54546. * @param name defines the block name
  54547. */
  54548. constructor(name: string);
  54549. /**
  54550. * Gets the current class name
  54551. * @returns the class name
  54552. */
  54553. getClassName(): string;
  54554. /**
  54555. * Gets the value input component
  54556. */
  54557. readonly value: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Gets the output component
  54560. */
  54561. readonly output: NodeMaterialConnectionPoint;
  54562. protected _buildBlock(state: NodeMaterialBuildState): this;
  54563. }
  54564. }
  54565. declare module BABYLON {
  54566. /**
  54567. * Effect Render Options
  54568. */
  54569. export interface IEffectRendererOptions {
  54570. /**
  54571. * Defines the vertices positions.
  54572. */
  54573. positions?: number[];
  54574. /**
  54575. * Defines the indices.
  54576. */
  54577. indices?: number[];
  54578. }
  54579. /**
  54580. * Helper class to render one or more effects
  54581. */
  54582. export class EffectRenderer {
  54583. private engine;
  54584. private static _DefaultOptions;
  54585. private _vertexBuffers;
  54586. private _indexBuffer;
  54587. private _ringBufferIndex;
  54588. private _ringScreenBuffer;
  54589. private _fullscreenViewport;
  54590. private _getNextFrameBuffer;
  54591. /**
  54592. * Creates an effect renderer
  54593. * @param engine the engine to use for rendering
  54594. * @param options defines the options of the effect renderer
  54595. */
  54596. constructor(engine: Engine, options?: IEffectRendererOptions);
  54597. /**
  54598. * Sets the current viewport in normalized coordinates 0-1
  54599. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54600. */
  54601. setViewport(viewport?: Viewport): void;
  54602. /**
  54603. * Binds the embedded attributes buffer to the effect.
  54604. * @param effect Defines the effect to bind the attributes for
  54605. */
  54606. bindBuffers(effect: Effect): void;
  54607. /**
  54608. * Sets the current effect wrapper to use during draw.
  54609. * The effect needs to be ready before calling this api.
  54610. * This also sets the default full screen position attribute.
  54611. * @param effectWrapper Defines the effect to draw with
  54612. */
  54613. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54614. /**
  54615. * Draws a full screen quad.
  54616. */
  54617. draw(): void;
  54618. /**
  54619. * renders one or more effects to a specified texture
  54620. * @param effectWrappers list of effects to renderer
  54621. * @param outputTexture texture to draw to, if null it will render to the screen
  54622. */
  54623. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54624. /**
  54625. * Disposes of the effect renderer
  54626. */
  54627. dispose(): void;
  54628. }
  54629. /**
  54630. * Options to create an EffectWrapper
  54631. */
  54632. interface EffectWrapperCreationOptions {
  54633. /**
  54634. * Engine to use to create the effect
  54635. */
  54636. engine: Engine;
  54637. /**
  54638. * Fragment shader for the effect
  54639. */
  54640. fragmentShader: string;
  54641. /**
  54642. * Vertex shader for the effect
  54643. */
  54644. vertexShader?: string;
  54645. /**
  54646. * Attributes to use in the shader
  54647. */
  54648. attributeNames?: Array<string>;
  54649. /**
  54650. * Uniforms to use in the shader
  54651. */
  54652. uniformNames?: Array<string>;
  54653. /**
  54654. * Texture sampler names to use in the shader
  54655. */
  54656. samplerNames?: Array<string>;
  54657. /**
  54658. * The friendly name of the effect displayed in Spector.
  54659. */
  54660. name?: string;
  54661. }
  54662. /**
  54663. * Wraps an effect to be used for rendering
  54664. */
  54665. export class EffectWrapper {
  54666. /**
  54667. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54668. */
  54669. onApplyObservable: Observable<{}>;
  54670. /**
  54671. * The underlying effect
  54672. */
  54673. effect: Effect;
  54674. /**
  54675. * Creates an effect to be renderer
  54676. * @param creationOptions options to create the effect
  54677. */
  54678. constructor(creationOptions: EffectWrapperCreationOptions);
  54679. /**
  54680. * Disposes of the effect wrapper
  54681. */
  54682. dispose(): void;
  54683. }
  54684. }
  54685. declare module BABYLON {
  54686. /**
  54687. * Helper class to push actions to a pool of workers.
  54688. */
  54689. export class WorkerPool implements IDisposable {
  54690. private _workerInfos;
  54691. private _pendingActions;
  54692. /**
  54693. * Constructor
  54694. * @param workers Array of workers to use for actions
  54695. */
  54696. constructor(workers: Array<Worker>);
  54697. /**
  54698. * Terminates all workers and clears any pending actions.
  54699. */
  54700. dispose(): void;
  54701. /**
  54702. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54703. * pended until a worker has completed its action.
  54704. * @param action The action to perform. Call onComplete when the action is complete.
  54705. */
  54706. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54707. private _execute;
  54708. }
  54709. }
  54710. declare module BABYLON {
  54711. /**
  54712. * Configuration for Draco compression
  54713. */
  54714. export interface IDracoCompressionConfiguration {
  54715. /**
  54716. * Configuration for the decoder.
  54717. */
  54718. decoder: {
  54719. /**
  54720. * The url to the WebAssembly module.
  54721. */
  54722. wasmUrl?: string;
  54723. /**
  54724. * The url to the WebAssembly binary.
  54725. */
  54726. wasmBinaryUrl?: string;
  54727. /**
  54728. * The url to the fallback JavaScript module.
  54729. */
  54730. fallbackUrl?: string;
  54731. };
  54732. }
  54733. /**
  54734. * Draco compression (https://google.github.io/draco/)
  54735. *
  54736. * This class wraps the Draco module.
  54737. *
  54738. * **Encoder**
  54739. *
  54740. * The encoder is not currently implemented.
  54741. *
  54742. * **Decoder**
  54743. *
  54744. * 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.
  54745. *
  54746. * To update the configuration, use the following code:
  54747. * ```javascript
  54748. * DracoCompression.Configuration = {
  54749. * decoder: {
  54750. * wasmUrl: "<url to the WebAssembly library>",
  54751. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54752. * fallbackUrl: "<url to the fallback JavaScript library>",
  54753. * }
  54754. * };
  54755. * ```
  54756. *
  54757. * 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.
  54758. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54759. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54760. *
  54761. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54762. * ```javascript
  54763. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54764. * ```
  54765. *
  54766. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54767. */
  54768. export class DracoCompression implements IDisposable {
  54769. private _workerPoolPromise?;
  54770. private _decoderModulePromise?;
  54771. /**
  54772. * The configuration. Defaults to the following urls:
  54773. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54774. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54775. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54776. */
  54777. static Configuration: IDracoCompressionConfiguration;
  54778. /**
  54779. * Returns true if the decoder configuration is available.
  54780. */
  54781. static readonly DecoderAvailable: boolean;
  54782. /**
  54783. * Default number of workers to create when creating the draco compression object.
  54784. */
  54785. static DefaultNumWorkers: number;
  54786. private static GetDefaultNumWorkers;
  54787. private static _Default;
  54788. /**
  54789. * Default instance for the draco compression object.
  54790. */
  54791. static readonly Default: DracoCompression;
  54792. /**
  54793. * Constructor
  54794. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54795. */
  54796. constructor(numWorkers?: number);
  54797. /**
  54798. * Stop all async operations and release resources.
  54799. */
  54800. dispose(): void;
  54801. /**
  54802. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54803. * @returns a promise that resolves when ready
  54804. */
  54805. whenReadyAsync(): Promise<void>;
  54806. /**
  54807. * Decode Draco compressed mesh data to vertex data.
  54808. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54809. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54810. * @returns A promise that resolves with the decoded vertex data
  54811. */
  54812. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54813. [kind: string]: number;
  54814. }): Promise<VertexData>;
  54815. }
  54816. }
  54817. declare module BABYLON {
  54818. /**
  54819. * Class for building Constructive Solid Geometry
  54820. */
  54821. export class CSG {
  54822. private polygons;
  54823. /**
  54824. * The world matrix
  54825. */
  54826. matrix: Matrix;
  54827. /**
  54828. * Stores the position
  54829. */
  54830. position: Vector3;
  54831. /**
  54832. * Stores the rotation
  54833. */
  54834. rotation: Vector3;
  54835. /**
  54836. * Stores the rotation quaternion
  54837. */
  54838. rotationQuaternion: Nullable<Quaternion>;
  54839. /**
  54840. * Stores the scaling vector
  54841. */
  54842. scaling: Vector3;
  54843. /**
  54844. * Convert the Mesh to CSG
  54845. * @param mesh The Mesh to convert to CSG
  54846. * @returns A new CSG from the Mesh
  54847. */
  54848. static FromMesh(mesh: Mesh): CSG;
  54849. /**
  54850. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54851. * @param polygons Polygons used to construct a CSG solid
  54852. */
  54853. private static FromPolygons;
  54854. /**
  54855. * Clones, or makes a deep copy, of the CSG
  54856. * @returns A new CSG
  54857. */
  54858. clone(): CSG;
  54859. /**
  54860. * Unions this CSG with another CSG
  54861. * @param csg The CSG to union against this CSG
  54862. * @returns The unioned CSG
  54863. */
  54864. union(csg: CSG): CSG;
  54865. /**
  54866. * Unions this CSG with another CSG in place
  54867. * @param csg The CSG to union against this CSG
  54868. */
  54869. unionInPlace(csg: CSG): void;
  54870. /**
  54871. * Subtracts this CSG with another CSG
  54872. * @param csg The CSG to subtract against this CSG
  54873. * @returns A new CSG
  54874. */
  54875. subtract(csg: CSG): CSG;
  54876. /**
  54877. * Subtracts this CSG with another CSG in place
  54878. * @param csg The CSG to subtact against this CSG
  54879. */
  54880. subtractInPlace(csg: CSG): void;
  54881. /**
  54882. * Intersect this CSG with another CSG
  54883. * @param csg The CSG to intersect against this CSG
  54884. * @returns A new CSG
  54885. */
  54886. intersect(csg: CSG): CSG;
  54887. /**
  54888. * Intersects this CSG with another CSG in place
  54889. * @param csg The CSG to intersect against this CSG
  54890. */
  54891. intersectInPlace(csg: CSG): void;
  54892. /**
  54893. * Return a new CSG solid with solid and empty space switched. This solid is
  54894. * not modified.
  54895. * @returns A new CSG solid with solid and empty space switched
  54896. */
  54897. inverse(): CSG;
  54898. /**
  54899. * Inverses the CSG in place
  54900. */
  54901. inverseInPlace(): void;
  54902. /**
  54903. * This is used to keep meshes transformations so they can be restored
  54904. * when we build back a Babylon Mesh
  54905. * NB : All CSG operations are performed in world coordinates
  54906. * @param csg The CSG to copy the transform attributes from
  54907. * @returns This CSG
  54908. */
  54909. copyTransformAttributes(csg: CSG): CSG;
  54910. /**
  54911. * Build Raw mesh from CSG
  54912. * Coordinates here are in world space
  54913. * @param name The name of the mesh geometry
  54914. * @param scene The Scene
  54915. * @param keepSubMeshes Specifies if the submeshes should be kept
  54916. * @returns A new Mesh
  54917. */
  54918. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54919. /**
  54920. * Build Mesh from CSG taking material and transforms into account
  54921. * @param name The name of the Mesh
  54922. * @param material The material of the Mesh
  54923. * @param scene The Scene
  54924. * @param keepSubMeshes Specifies if submeshes should be kept
  54925. * @returns The new Mesh
  54926. */
  54927. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  54928. }
  54929. }
  54930. declare module BABYLON {
  54931. /**
  54932. * Class used to create a trail following a mesh
  54933. */
  54934. export class TrailMesh extends Mesh {
  54935. private _generator;
  54936. private _autoStart;
  54937. private _running;
  54938. private _diameter;
  54939. private _length;
  54940. private _sectionPolygonPointsCount;
  54941. private _sectionVectors;
  54942. private _sectionNormalVectors;
  54943. private _beforeRenderObserver;
  54944. /**
  54945. * @constructor
  54946. * @param name The value used by scene.getMeshByName() to do a lookup.
  54947. * @param generator The mesh to generate a trail.
  54948. * @param scene The scene to add this mesh to.
  54949. * @param diameter Diameter of trailing mesh. Default is 1.
  54950. * @param length Length of trailing mesh. Default is 60.
  54951. * @param autoStart Automatically start trailing mesh. Default true.
  54952. */
  54953. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54954. /**
  54955. * "TrailMesh"
  54956. * @returns "TrailMesh"
  54957. */
  54958. getClassName(): string;
  54959. private _createMesh;
  54960. /**
  54961. * Start trailing mesh.
  54962. */
  54963. start(): void;
  54964. /**
  54965. * Stop trailing mesh.
  54966. */
  54967. stop(): void;
  54968. /**
  54969. * Update trailing mesh geometry.
  54970. */
  54971. update(): void;
  54972. /**
  54973. * Returns a new TrailMesh object.
  54974. * @param name is a string, the name given to the new mesh
  54975. * @param newGenerator use new generator object for cloned trail mesh
  54976. * @returns a new mesh
  54977. */
  54978. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54979. /**
  54980. * Serializes this trail mesh
  54981. * @param serializationObject object to write serialization to
  54982. */
  54983. serialize(serializationObject: any): void;
  54984. /**
  54985. * Parses a serialized trail mesh
  54986. * @param parsedMesh the serialized mesh
  54987. * @param scene the scene to create the trail mesh in
  54988. * @returns the created trail mesh
  54989. */
  54990. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54991. }
  54992. }
  54993. declare module BABYLON {
  54994. /**
  54995. * Class containing static functions to help procedurally build meshes
  54996. */
  54997. export class TiledBoxBuilder {
  54998. /**
  54999. * Creates a box mesh
  55000. * 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)
  55001. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55003. * * 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
  55004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55005. * @param name defines the name of the mesh
  55006. * @param options defines the options used to create the mesh
  55007. * @param scene defines the hosting scene
  55008. * @returns the box mesh
  55009. */
  55010. static CreateTiledBox(name: string, options: {
  55011. pattern?: number;
  55012. width?: number;
  55013. height?: number;
  55014. depth?: number;
  55015. tileSize?: number;
  55016. tileWidth?: number;
  55017. tileHeight?: number;
  55018. alignHorizontal?: number;
  55019. alignVertical?: number;
  55020. faceUV?: Vector4[];
  55021. faceColors?: Color4[];
  55022. sideOrientation?: number;
  55023. updatable?: boolean;
  55024. }, scene?: Nullable<Scene>): Mesh;
  55025. }
  55026. }
  55027. declare module BABYLON {
  55028. /**
  55029. * Class containing static functions to help procedurally build meshes
  55030. */
  55031. export class TorusKnotBuilder {
  55032. /**
  55033. * Creates a torus knot mesh
  55034. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55035. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55036. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55037. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55039. * * 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
  55040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55041. * @param name defines the name of the mesh
  55042. * @param options defines the options used to create the mesh
  55043. * @param scene defines the hosting scene
  55044. * @returns the torus knot mesh
  55045. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55046. */
  55047. static CreateTorusKnot(name: string, options: {
  55048. radius?: number;
  55049. tube?: number;
  55050. radialSegments?: number;
  55051. tubularSegments?: number;
  55052. p?: number;
  55053. q?: number;
  55054. updatable?: boolean;
  55055. sideOrientation?: number;
  55056. frontUVs?: Vector4;
  55057. backUVs?: Vector4;
  55058. }, scene: any): Mesh;
  55059. }
  55060. }
  55061. declare module BABYLON {
  55062. /**
  55063. * Polygon
  55064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55065. */
  55066. export class Polygon {
  55067. /**
  55068. * Creates a rectangle
  55069. * @param xmin bottom X coord
  55070. * @param ymin bottom Y coord
  55071. * @param xmax top X coord
  55072. * @param ymax top Y coord
  55073. * @returns points that make the resulting rectation
  55074. */
  55075. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55076. /**
  55077. * Creates a circle
  55078. * @param radius radius of circle
  55079. * @param cx scale in x
  55080. * @param cy scale in y
  55081. * @param numberOfSides number of sides that make up the circle
  55082. * @returns points that make the resulting circle
  55083. */
  55084. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55085. /**
  55086. * Creates a polygon from input string
  55087. * @param input Input polygon data
  55088. * @returns the parsed points
  55089. */
  55090. static Parse(input: string): Vector2[];
  55091. /**
  55092. * Starts building a polygon from x and y coordinates
  55093. * @param x x coordinate
  55094. * @param y y coordinate
  55095. * @returns the started path2
  55096. */
  55097. static StartingAt(x: number, y: number): Path2;
  55098. }
  55099. /**
  55100. * Builds a polygon
  55101. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55102. */
  55103. export class PolygonMeshBuilder {
  55104. private _points;
  55105. private _outlinepoints;
  55106. private _holes;
  55107. private _name;
  55108. private _scene;
  55109. private _epoints;
  55110. private _eholes;
  55111. private _addToepoint;
  55112. /**
  55113. * Babylon reference to the earcut plugin.
  55114. */
  55115. bjsEarcut: any;
  55116. /**
  55117. * Creates a PolygonMeshBuilder
  55118. * @param name name of the builder
  55119. * @param contours Path of the polygon
  55120. * @param scene scene to add to when creating the mesh
  55121. * @param earcutInjection can be used to inject your own earcut reference
  55122. */
  55123. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55124. /**
  55125. * Adds a whole within the polygon
  55126. * @param hole Array of points defining the hole
  55127. * @returns this
  55128. */
  55129. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55130. /**
  55131. * Creates the polygon
  55132. * @param updatable If the mesh should be updatable
  55133. * @param depth The depth of the mesh created
  55134. * @returns the created mesh
  55135. */
  55136. build(updatable?: boolean, depth?: number): Mesh;
  55137. /**
  55138. * Creates the polygon
  55139. * @param depth The depth of the mesh created
  55140. * @returns the created VertexData
  55141. */
  55142. buildVertexData(depth?: number): VertexData;
  55143. /**
  55144. * Adds a side to the polygon
  55145. * @param positions points that make the polygon
  55146. * @param normals normals of the polygon
  55147. * @param uvs uvs of the polygon
  55148. * @param indices indices of the polygon
  55149. * @param bounds bounds of the polygon
  55150. * @param points points of the polygon
  55151. * @param depth depth of the polygon
  55152. * @param flip flip of the polygon
  55153. */
  55154. private addSide;
  55155. }
  55156. }
  55157. declare module BABYLON {
  55158. /**
  55159. * Class containing static functions to help procedurally build meshes
  55160. */
  55161. export class PolygonBuilder {
  55162. /**
  55163. * Creates a polygon mesh
  55164. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55165. * * 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
  55166. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55168. * * 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)
  55169. * * Remember you can only change the shape positions, not their number when updating a polygon
  55170. * @param name defines the name of the mesh
  55171. * @param options defines the options used to create the mesh
  55172. * @param scene defines the hosting scene
  55173. * @param earcutInjection can be used to inject your own earcut reference
  55174. * @returns the polygon mesh
  55175. */
  55176. static CreatePolygon(name: string, options: {
  55177. shape: Vector3[];
  55178. holes?: Vector3[][];
  55179. depth?: number;
  55180. faceUV?: Vector4[];
  55181. faceColors?: Color4[];
  55182. updatable?: boolean;
  55183. sideOrientation?: number;
  55184. frontUVs?: Vector4;
  55185. backUVs?: Vector4;
  55186. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55187. /**
  55188. * Creates an extruded polygon mesh, with depth in the Y direction.
  55189. * * 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)
  55190. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55191. * @param name defines the name of the mesh
  55192. * @param options defines the options used to create the mesh
  55193. * @param scene defines the hosting scene
  55194. * @param earcutInjection can be used to inject your own earcut reference
  55195. * @returns the polygon mesh
  55196. */
  55197. static ExtrudePolygon(name: string, options: {
  55198. shape: Vector3[];
  55199. holes?: Vector3[][];
  55200. depth?: number;
  55201. faceUV?: Vector4[];
  55202. faceColors?: Color4[];
  55203. updatable?: boolean;
  55204. sideOrientation?: number;
  55205. frontUVs?: Vector4;
  55206. backUVs?: Vector4;
  55207. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55208. }
  55209. }
  55210. declare module BABYLON {
  55211. /**
  55212. * Class containing static functions to help procedurally build meshes
  55213. */
  55214. export class LatheBuilder {
  55215. /**
  55216. * Creates lathe mesh.
  55217. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55218. * * 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
  55219. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55220. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55221. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55222. * * 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
  55223. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55224. * * 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
  55225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55226. * * 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
  55227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55229. * @param name defines the name of the mesh
  55230. * @param options defines the options used to create the mesh
  55231. * @param scene defines the hosting scene
  55232. * @returns the lathe mesh
  55233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55234. */
  55235. static CreateLathe(name: string, options: {
  55236. shape: Vector3[];
  55237. radius?: number;
  55238. tessellation?: number;
  55239. clip?: number;
  55240. arc?: number;
  55241. closed?: boolean;
  55242. updatable?: boolean;
  55243. sideOrientation?: number;
  55244. frontUVs?: Vector4;
  55245. backUVs?: Vector4;
  55246. cap?: number;
  55247. invertUV?: boolean;
  55248. }, scene?: Nullable<Scene>): Mesh;
  55249. }
  55250. }
  55251. declare module BABYLON {
  55252. /**
  55253. * Class containing static functions to help procedurally build meshes
  55254. */
  55255. export class TiledPlaneBuilder {
  55256. /**
  55257. * Creates a tiled plane mesh
  55258. * * The parameter `pattern` will, depending on value, do nothing or
  55259. * * * flip (reflect about central vertical) alternate tiles across and up
  55260. * * * flip every tile on alternate rows
  55261. * * * rotate (180 degs) alternate tiles across and up
  55262. * * * rotate every tile on alternate rows
  55263. * * * flip and rotate alternate tiles across and up
  55264. * * * flip and rotate every tile on alternate rows
  55265. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55266. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55267. * * 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
  55268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55269. * * 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)
  55270. * * 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)
  55271. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55272. * @param name defines the name of the mesh
  55273. * @param options defines the options used to create the mesh
  55274. * @param scene defines the hosting scene
  55275. * @returns the box mesh
  55276. */
  55277. static CreateTiledPlane(name: string, options: {
  55278. pattern?: number;
  55279. tileSize?: number;
  55280. tileWidth?: number;
  55281. tileHeight?: number;
  55282. size?: number;
  55283. width?: number;
  55284. height?: number;
  55285. alignHorizontal?: number;
  55286. alignVertical?: number;
  55287. sideOrientation?: number;
  55288. frontUVs?: Vector4;
  55289. backUVs?: Vector4;
  55290. updatable?: boolean;
  55291. }, scene?: Nullable<Scene>): Mesh;
  55292. }
  55293. }
  55294. declare module BABYLON {
  55295. /**
  55296. * Class containing static functions to help procedurally build meshes
  55297. */
  55298. export class TubeBuilder {
  55299. /**
  55300. * Creates a tube mesh.
  55301. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55302. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55303. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55304. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55305. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55306. * * 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)
  55307. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55308. * * 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
  55309. * * 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
  55310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55311. * * 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
  55312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55314. * @param name defines the name of the mesh
  55315. * @param options defines the options used to create the mesh
  55316. * @param scene defines the hosting scene
  55317. * @returns the tube mesh
  55318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55319. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55320. */
  55321. static CreateTube(name: string, options: {
  55322. path: Vector3[];
  55323. radius?: number;
  55324. tessellation?: number;
  55325. radiusFunction?: {
  55326. (i: number, distance: number): number;
  55327. };
  55328. cap?: number;
  55329. arc?: number;
  55330. updatable?: boolean;
  55331. sideOrientation?: number;
  55332. frontUVs?: Vector4;
  55333. backUVs?: Vector4;
  55334. instance?: Mesh;
  55335. invertUV?: boolean;
  55336. }, scene?: Nullable<Scene>): Mesh;
  55337. }
  55338. }
  55339. declare module BABYLON {
  55340. /**
  55341. * Class containing static functions to help procedurally build meshes
  55342. */
  55343. export class IcoSphereBuilder {
  55344. /**
  55345. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55346. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55347. * * 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`)
  55348. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55349. * * 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
  55350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55351. * * 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
  55352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55353. * @param name defines the name of the mesh
  55354. * @param options defines the options used to create the mesh
  55355. * @param scene defines the hosting scene
  55356. * @returns the icosahedron mesh
  55357. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55358. */
  55359. static CreateIcoSphere(name: string, options: {
  55360. radius?: number;
  55361. radiusX?: number;
  55362. radiusY?: number;
  55363. radiusZ?: number;
  55364. flat?: boolean;
  55365. subdivisions?: number;
  55366. sideOrientation?: number;
  55367. frontUVs?: Vector4;
  55368. backUVs?: Vector4;
  55369. updatable?: boolean;
  55370. }, scene?: Nullable<Scene>): Mesh;
  55371. }
  55372. }
  55373. declare module BABYLON {
  55374. /**
  55375. * Class containing static functions to help procedurally build meshes
  55376. */
  55377. export class DecalBuilder {
  55378. /**
  55379. * Creates a decal mesh.
  55380. * 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
  55381. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55382. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55383. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55384. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55385. * @param name defines the name of the mesh
  55386. * @param sourceMesh defines the mesh where the decal must be applied
  55387. * @param options defines the options used to create the mesh
  55388. * @param scene defines the hosting scene
  55389. * @returns the decal mesh
  55390. * @see https://doc.babylonjs.com/how_to/decals
  55391. */
  55392. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55393. position?: Vector3;
  55394. normal?: Vector3;
  55395. size?: Vector3;
  55396. angle?: number;
  55397. }): Mesh;
  55398. }
  55399. }
  55400. declare module BABYLON {
  55401. /**
  55402. * Class containing static functions to help procedurally build meshes
  55403. */
  55404. export class MeshBuilder {
  55405. /**
  55406. * Creates a box mesh
  55407. * * The parameter `size` sets the size (float) of each box side (default 1)
  55408. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55409. * * 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)
  55410. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55412. * * 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
  55413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55414. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55415. * @param name defines the name of the mesh
  55416. * @param options defines the options used to create the mesh
  55417. * @param scene defines the hosting scene
  55418. * @returns the box mesh
  55419. */
  55420. static CreateBox(name: string, options: {
  55421. size?: number;
  55422. width?: number;
  55423. height?: number;
  55424. depth?: number;
  55425. faceUV?: Vector4[];
  55426. faceColors?: Color4[];
  55427. sideOrientation?: number;
  55428. frontUVs?: Vector4;
  55429. backUVs?: Vector4;
  55430. updatable?: boolean;
  55431. }, scene?: Nullable<Scene>): Mesh;
  55432. /**
  55433. * Creates a tiled box mesh
  55434. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55436. * @param name defines the name of the mesh
  55437. * @param options defines the options used to create the mesh
  55438. * @param scene defines the hosting scene
  55439. * @returns the tiled box mesh
  55440. */
  55441. static CreateTiledBox(name: string, options: {
  55442. pattern?: number;
  55443. size?: number;
  55444. width?: number;
  55445. height?: number;
  55446. depth: number;
  55447. tileSize?: number;
  55448. tileWidth?: number;
  55449. tileHeight?: number;
  55450. faceUV?: Vector4[];
  55451. faceColors?: Color4[];
  55452. alignHorizontal?: number;
  55453. alignVertical?: number;
  55454. sideOrientation?: number;
  55455. updatable?: boolean;
  55456. }, scene?: Nullable<Scene>): Mesh;
  55457. /**
  55458. * Creates a sphere mesh
  55459. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55460. * * 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`)
  55461. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55462. * * 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
  55463. * * 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)
  55464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55465. * * 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
  55466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55467. * @param name defines the name of the mesh
  55468. * @param options defines the options used to create the mesh
  55469. * @param scene defines the hosting scene
  55470. * @returns the sphere mesh
  55471. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55472. */
  55473. static CreateSphere(name: string, options: {
  55474. segments?: number;
  55475. diameter?: number;
  55476. diameterX?: number;
  55477. diameterY?: number;
  55478. diameterZ?: number;
  55479. arc?: number;
  55480. slice?: number;
  55481. sideOrientation?: number;
  55482. frontUVs?: Vector4;
  55483. backUVs?: Vector4;
  55484. updatable?: boolean;
  55485. }, scene?: Nullable<Scene>): Mesh;
  55486. /**
  55487. * Creates a plane polygonal mesh. By default, this is a disc
  55488. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55489. * * 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
  55490. * * 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
  55491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55492. * * 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
  55493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55494. * @param name defines the name of the mesh
  55495. * @param options defines the options used to create the mesh
  55496. * @param scene defines the hosting scene
  55497. * @returns the plane polygonal mesh
  55498. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55499. */
  55500. static CreateDisc(name: string, options: {
  55501. radius?: number;
  55502. tessellation?: number;
  55503. arc?: number;
  55504. updatable?: boolean;
  55505. sideOrientation?: number;
  55506. frontUVs?: Vector4;
  55507. backUVs?: Vector4;
  55508. }, scene?: Nullable<Scene>): Mesh;
  55509. /**
  55510. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55511. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55512. * * 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`)
  55513. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55514. * * 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
  55515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55516. * * 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
  55517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55518. * @param name defines the name of the mesh
  55519. * @param options defines the options used to create the mesh
  55520. * @param scene defines the hosting scene
  55521. * @returns the icosahedron mesh
  55522. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55523. */
  55524. static CreateIcoSphere(name: string, options: {
  55525. radius?: number;
  55526. radiusX?: number;
  55527. radiusY?: number;
  55528. radiusZ?: number;
  55529. flat?: boolean;
  55530. subdivisions?: number;
  55531. sideOrientation?: number;
  55532. frontUVs?: Vector4;
  55533. backUVs?: Vector4;
  55534. updatable?: boolean;
  55535. }, scene?: Nullable<Scene>): Mesh;
  55536. /**
  55537. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55538. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55539. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55540. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55541. * * 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
  55542. * * 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
  55543. * * 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
  55544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55545. * * 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
  55546. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55547. * * 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
  55548. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55549. * * 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
  55550. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55552. * @param name defines the name of the mesh
  55553. * @param options defines the options used to create the mesh
  55554. * @param scene defines the hosting scene
  55555. * @returns the ribbon mesh
  55556. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55557. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55558. */
  55559. static CreateRibbon(name: string, options: {
  55560. pathArray: Vector3[][];
  55561. closeArray?: boolean;
  55562. closePath?: boolean;
  55563. offset?: number;
  55564. updatable?: boolean;
  55565. sideOrientation?: number;
  55566. frontUVs?: Vector4;
  55567. backUVs?: Vector4;
  55568. instance?: Mesh;
  55569. invertUV?: boolean;
  55570. uvs?: Vector2[];
  55571. colors?: Color4[];
  55572. }, scene?: Nullable<Scene>): Mesh;
  55573. /**
  55574. * Creates a cylinder or a cone mesh
  55575. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55576. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55577. * * 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.
  55578. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55579. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55580. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55581. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55582. * * 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).
  55583. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55584. * * 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).
  55585. * * 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
  55586. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55587. * * 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
  55588. * * 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.
  55589. * * If `enclose` is false, a ring surface is one element.
  55590. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55591. * * 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
  55592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55593. * * 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
  55594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55595. * @param name defines the name of the mesh
  55596. * @param options defines the options used to create the mesh
  55597. * @param scene defines the hosting scene
  55598. * @returns the cylinder mesh
  55599. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55600. */
  55601. static CreateCylinder(name: string, options: {
  55602. height?: number;
  55603. diameterTop?: number;
  55604. diameterBottom?: number;
  55605. diameter?: number;
  55606. tessellation?: number;
  55607. subdivisions?: number;
  55608. arc?: number;
  55609. faceColors?: Color4[];
  55610. faceUV?: Vector4[];
  55611. updatable?: boolean;
  55612. hasRings?: boolean;
  55613. enclose?: boolean;
  55614. cap?: number;
  55615. sideOrientation?: number;
  55616. frontUVs?: Vector4;
  55617. backUVs?: Vector4;
  55618. }, scene?: Nullable<Scene>): Mesh;
  55619. /**
  55620. * Creates a torus mesh
  55621. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55622. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55623. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55625. * * 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
  55626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55627. * @param name defines the name of the mesh
  55628. * @param options defines the options used to create the mesh
  55629. * @param scene defines the hosting scene
  55630. * @returns the torus mesh
  55631. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55632. */
  55633. static CreateTorus(name: string, options: {
  55634. diameter?: number;
  55635. thickness?: number;
  55636. tessellation?: number;
  55637. updatable?: boolean;
  55638. sideOrientation?: number;
  55639. frontUVs?: Vector4;
  55640. backUVs?: Vector4;
  55641. }, scene?: Nullable<Scene>): Mesh;
  55642. /**
  55643. * Creates a torus knot mesh
  55644. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55645. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55646. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55647. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55649. * * 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
  55650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55651. * @param name defines the name of the mesh
  55652. * @param options defines the options used to create the mesh
  55653. * @param scene defines the hosting scene
  55654. * @returns the torus knot mesh
  55655. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55656. */
  55657. static CreateTorusKnot(name: string, options: {
  55658. radius?: number;
  55659. tube?: number;
  55660. radialSegments?: number;
  55661. tubularSegments?: number;
  55662. p?: number;
  55663. q?: number;
  55664. updatable?: boolean;
  55665. sideOrientation?: number;
  55666. frontUVs?: Vector4;
  55667. backUVs?: Vector4;
  55668. }, scene?: Nullable<Scene>): Mesh;
  55669. /**
  55670. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55671. * * 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
  55672. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55673. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55674. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55675. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55676. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55677. * * 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
  55678. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55681. * @param name defines the name of the new line system
  55682. * @param options defines the options used to create the line system
  55683. * @param scene defines the hosting scene
  55684. * @returns a new line system mesh
  55685. */
  55686. static CreateLineSystem(name: string, options: {
  55687. lines: Vector3[][];
  55688. updatable?: boolean;
  55689. instance?: Nullable<LinesMesh>;
  55690. colors?: Nullable<Color4[][]>;
  55691. useVertexAlpha?: boolean;
  55692. }, scene: Nullable<Scene>): LinesMesh;
  55693. /**
  55694. * Creates a line mesh
  55695. * 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
  55696. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55697. * * The parameter `points` is an array successive Vector3
  55698. * * 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
  55699. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55700. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55701. * * When updating an instance, remember that only point positions can change, not the number of points
  55702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55704. * @param name defines the name of the new line system
  55705. * @param options defines the options used to create the line system
  55706. * @param scene defines the hosting scene
  55707. * @returns a new line mesh
  55708. */
  55709. static CreateLines(name: string, options: {
  55710. points: Vector3[];
  55711. updatable?: boolean;
  55712. instance?: Nullable<LinesMesh>;
  55713. colors?: Color4[];
  55714. useVertexAlpha?: boolean;
  55715. }, scene?: Nullable<Scene>): LinesMesh;
  55716. /**
  55717. * Creates a dashed line mesh
  55718. * * 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
  55719. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55720. * * The parameter `points` is an array successive Vector3
  55721. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55722. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55723. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55724. * * 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
  55725. * * When updating an instance, remember that only point positions can change, not the number of points
  55726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55727. * @param name defines the name of the mesh
  55728. * @param options defines the options used to create the mesh
  55729. * @param scene defines the hosting scene
  55730. * @returns the dashed line mesh
  55731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55732. */
  55733. static CreateDashedLines(name: string, options: {
  55734. points: Vector3[];
  55735. dashSize?: number;
  55736. gapSize?: number;
  55737. dashNb?: number;
  55738. updatable?: boolean;
  55739. instance?: LinesMesh;
  55740. }, scene?: Nullable<Scene>): LinesMesh;
  55741. /**
  55742. * 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.
  55743. * * 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.
  55744. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55745. * * 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.
  55746. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55747. * * 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
  55748. * * 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
  55749. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55751. * * 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
  55752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55754. * @param name defines the name of the mesh
  55755. * @param options defines the options used to create the mesh
  55756. * @param scene defines the hosting scene
  55757. * @returns the extruded shape mesh
  55758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55760. */
  55761. static ExtrudeShape(name: string, options: {
  55762. shape: Vector3[];
  55763. path: Vector3[];
  55764. scale?: number;
  55765. rotation?: number;
  55766. cap?: number;
  55767. updatable?: boolean;
  55768. sideOrientation?: number;
  55769. frontUVs?: Vector4;
  55770. backUVs?: Vector4;
  55771. instance?: Mesh;
  55772. invertUV?: boolean;
  55773. }, scene?: Nullable<Scene>): Mesh;
  55774. /**
  55775. * Creates an custom extruded shape mesh.
  55776. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55777. * * 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.
  55778. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55779. * * 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
  55780. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55781. * * 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
  55782. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55783. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55784. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55785. * * 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
  55786. * * 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
  55787. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55789. * * 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
  55790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55792. * @param name defines the name of the mesh
  55793. * @param options defines the options used to create the mesh
  55794. * @param scene defines the hosting scene
  55795. * @returns the custom extruded shape mesh
  55796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55797. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55799. */
  55800. static ExtrudeShapeCustom(name: string, options: {
  55801. shape: Vector3[];
  55802. path: Vector3[];
  55803. scaleFunction?: any;
  55804. rotationFunction?: any;
  55805. ribbonCloseArray?: boolean;
  55806. ribbonClosePath?: boolean;
  55807. cap?: number;
  55808. updatable?: boolean;
  55809. sideOrientation?: number;
  55810. frontUVs?: Vector4;
  55811. backUVs?: Vector4;
  55812. instance?: Mesh;
  55813. invertUV?: boolean;
  55814. }, scene?: Nullable<Scene>): Mesh;
  55815. /**
  55816. * Creates lathe mesh.
  55817. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55818. * * 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
  55819. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55820. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55821. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55822. * * 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
  55823. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55824. * * 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
  55825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55826. * * 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
  55827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55829. * @param name defines the name of the mesh
  55830. * @param options defines the options used to create the mesh
  55831. * @param scene defines the hosting scene
  55832. * @returns the lathe mesh
  55833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55834. */
  55835. static CreateLathe(name: string, options: {
  55836. shape: Vector3[];
  55837. radius?: number;
  55838. tessellation?: number;
  55839. clip?: number;
  55840. arc?: number;
  55841. closed?: boolean;
  55842. updatable?: boolean;
  55843. sideOrientation?: number;
  55844. frontUVs?: Vector4;
  55845. backUVs?: Vector4;
  55846. cap?: number;
  55847. invertUV?: boolean;
  55848. }, scene?: Nullable<Scene>): Mesh;
  55849. /**
  55850. * Creates a tiled plane mesh
  55851. * * You can set a limited pattern arrangement with the tiles
  55852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55853. * * 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
  55854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55855. * @param name defines the name of the mesh
  55856. * @param options defines the options used to create the mesh
  55857. * @param scene defines the hosting scene
  55858. * @returns the plane mesh
  55859. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55860. */
  55861. static CreateTiledPlane(name: string, options: {
  55862. pattern?: number;
  55863. tileSize?: number;
  55864. tileWidth?: number;
  55865. tileHeight?: number;
  55866. size?: number;
  55867. width?: number;
  55868. height?: number;
  55869. alignHorizontal?: number;
  55870. alignVertical?: number;
  55871. sideOrientation?: number;
  55872. frontUVs?: Vector4;
  55873. backUVs?: Vector4;
  55874. updatable?: boolean;
  55875. }, scene?: Nullable<Scene>): Mesh;
  55876. /**
  55877. * Creates a plane mesh
  55878. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55879. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55880. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55882. * * 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
  55883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55884. * @param name defines the name of the mesh
  55885. * @param options defines the options used to create the mesh
  55886. * @param scene defines the hosting scene
  55887. * @returns the plane mesh
  55888. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55889. */
  55890. static CreatePlane(name: string, options: {
  55891. size?: number;
  55892. width?: number;
  55893. height?: number;
  55894. sideOrientation?: number;
  55895. frontUVs?: Vector4;
  55896. backUVs?: Vector4;
  55897. updatable?: boolean;
  55898. sourcePlane?: Plane;
  55899. }, scene?: Nullable<Scene>): Mesh;
  55900. /**
  55901. * Creates a ground mesh
  55902. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55903. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55905. * @param name defines the name of the mesh
  55906. * @param options defines the options used to create the mesh
  55907. * @param scene defines the hosting scene
  55908. * @returns the ground mesh
  55909. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55910. */
  55911. static CreateGround(name: string, options: {
  55912. width?: number;
  55913. height?: number;
  55914. subdivisions?: number;
  55915. subdivisionsX?: number;
  55916. subdivisionsY?: number;
  55917. updatable?: boolean;
  55918. }, scene?: Nullable<Scene>): Mesh;
  55919. /**
  55920. * Creates a tiled ground mesh
  55921. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55922. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55923. * * 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
  55924. * * 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
  55925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55926. * @param name defines the name of the mesh
  55927. * @param options defines the options used to create the mesh
  55928. * @param scene defines the hosting scene
  55929. * @returns the tiled ground mesh
  55930. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55931. */
  55932. static CreateTiledGround(name: string, options: {
  55933. xmin: number;
  55934. zmin: number;
  55935. xmax: number;
  55936. zmax: number;
  55937. subdivisions?: {
  55938. w: number;
  55939. h: number;
  55940. };
  55941. precision?: {
  55942. w: number;
  55943. h: number;
  55944. };
  55945. updatable?: boolean;
  55946. }, scene?: Nullable<Scene>): Mesh;
  55947. /**
  55948. * Creates a ground mesh from a height map
  55949. * * The parameter `url` sets the URL of the height map image resource.
  55950. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55951. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55952. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55953. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55954. * * 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.
  55955. * * 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).
  55956. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55958. * @param name defines the name of the mesh
  55959. * @param url defines the url to the height map
  55960. * @param options defines the options used to create the mesh
  55961. * @param scene defines the hosting scene
  55962. * @returns the ground mesh
  55963. * @see https://doc.babylonjs.com/babylon101/height_map
  55964. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55965. */
  55966. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55967. width?: number;
  55968. height?: number;
  55969. subdivisions?: number;
  55970. minHeight?: number;
  55971. maxHeight?: number;
  55972. colorFilter?: Color3;
  55973. alphaFilter?: number;
  55974. updatable?: boolean;
  55975. onReady?: (mesh: GroundMesh) => void;
  55976. }, scene?: Nullable<Scene>): GroundMesh;
  55977. /**
  55978. * Creates a polygon mesh
  55979. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55980. * * 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
  55981. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55983. * * 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)
  55984. * * Remember you can only change the shape positions, not their number when updating a polygon
  55985. * @param name defines the name of the mesh
  55986. * @param options defines the options used to create the mesh
  55987. * @param scene defines the hosting scene
  55988. * @param earcutInjection can be used to inject your own earcut reference
  55989. * @returns the polygon mesh
  55990. */
  55991. static CreatePolygon(name: string, options: {
  55992. shape: Vector3[];
  55993. holes?: Vector3[][];
  55994. depth?: number;
  55995. faceUV?: Vector4[];
  55996. faceColors?: Color4[];
  55997. updatable?: boolean;
  55998. sideOrientation?: number;
  55999. frontUVs?: Vector4;
  56000. backUVs?: Vector4;
  56001. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56002. /**
  56003. * Creates an extruded polygon mesh, with depth in the Y direction.
  56004. * * 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)
  56005. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56006. * @param name defines the name of the mesh
  56007. * @param options defines the options used to create the mesh
  56008. * @param scene defines the hosting scene
  56009. * @param earcutInjection can be used to inject your own earcut reference
  56010. * @returns the polygon mesh
  56011. */
  56012. static ExtrudePolygon(name: string, options: {
  56013. shape: Vector3[];
  56014. holes?: Vector3[][];
  56015. depth?: number;
  56016. faceUV?: Vector4[];
  56017. faceColors?: Color4[];
  56018. updatable?: boolean;
  56019. sideOrientation?: number;
  56020. frontUVs?: Vector4;
  56021. backUVs?: Vector4;
  56022. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56023. /**
  56024. * Creates a tube mesh.
  56025. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56026. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56027. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56028. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56029. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56030. * * 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)
  56031. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56032. * * 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
  56033. * * 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
  56034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56035. * * 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
  56036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56038. * @param name defines the name of the mesh
  56039. * @param options defines the options used to create the mesh
  56040. * @param scene defines the hosting scene
  56041. * @returns the tube mesh
  56042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56043. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56044. */
  56045. static CreateTube(name: string, options: {
  56046. path: Vector3[];
  56047. radius?: number;
  56048. tessellation?: number;
  56049. radiusFunction?: {
  56050. (i: number, distance: number): number;
  56051. };
  56052. cap?: number;
  56053. arc?: number;
  56054. updatable?: boolean;
  56055. sideOrientation?: number;
  56056. frontUVs?: Vector4;
  56057. backUVs?: Vector4;
  56058. instance?: Mesh;
  56059. invertUV?: boolean;
  56060. }, scene?: Nullable<Scene>): Mesh;
  56061. /**
  56062. * Creates a polyhedron mesh
  56063. * * 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
  56064. * * The parameter `size` (positive float, default 1) sets the polygon size
  56065. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56066. * * 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`
  56067. * * 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
  56068. * * 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)`)
  56069. * * 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
  56070. * * 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
  56071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56072. * * 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
  56073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56074. * @param name defines the name of the mesh
  56075. * @param options defines the options used to create the mesh
  56076. * @param scene defines the hosting scene
  56077. * @returns the polyhedron mesh
  56078. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56079. */
  56080. static CreatePolyhedron(name: string, options: {
  56081. type?: number;
  56082. size?: number;
  56083. sizeX?: number;
  56084. sizeY?: number;
  56085. sizeZ?: number;
  56086. custom?: any;
  56087. faceUV?: Vector4[];
  56088. faceColors?: Color4[];
  56089. flat?: boolean;
  56090. updatable?: boolean;
  56091. sideOrientation?: number;
  56092. frontUVs?: Vector4;
  56093. backUVs?: Vector4;
  56094. }, scene?: Nullable<Scene>): Mesh;
  56095. /**
  56096. * Creates a decal mesh.
  56097. * 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
  56098. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56099. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56100. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56101. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56102. * @param name defines the name of the mesh
  56103. * @param sourceMesh defines the mesh where the decal must be applied
  56104. * @param options defines the options used to create the mesh
  56105. * @param scene defines the hosting scene
  56106. * @returns the decal mesh
  56107. * @see https://doc.babylonjs.com/how_to/decals
  56108. */
  56109. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56110. position?: Vector3;
  56111. normal?: Vector3;
  56112. size?: Vector3;
  56113. angle?: number;
  56114. }): Mesh;
  56115. }
  56116. }
  56117. declare module BABYLON {
  56118. /**
  56119. * A simplifier interface for future simplification implementations
  56120. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56121. */
  56122. export interface ISimplifier {
  56123. /**
  56124. * Simplification of a given mesh according to the given settings.
  56125. * Since this requires computation, it is assumed that the function runs async.
  56126. * @param settings The settings of the simplification, including quality and distance
  56127. * @param successCallback A callback that will be called after the mesh was simplified.
  56128. * @param errorCallback in case of an error, this callback will be called. optional.
  56129. */
  56130. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56131. }
  56132. /**
  56133. * Expected simplification settings.
  56134. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56135. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56136. */
  56137. export interface ISimplificationSettings {
  56138. /**
  56139. * Gets or sets the expected quality
  56140. */
  56141. quality: number;
  56142. /**
  56143. * Gets or sets the distance when this optimized version should be used
  56144. */
  56145. distance: number;
  56146. /**
  56147. * Gets an already optimized mesh
  56148. */
  56149. optimizeMesh?: boolean;
  56150. }
  56151. /**
  56152. * Class used to specify simplification options
  56153. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56154. */
  56155. export class SimplificationSettings implements ISimplificationSettings {
  56156. /** expected quality */
  56157. quality: number;
  56158. /** distance when this optimized version should be used */
  56159. distance: number;
  56160. /** already optimized mesh */
  56161. optimizeMesh?: boolean | undefined;
  56162. /**
  56163. * Creates a SimplificationSettings
  56164. * @param quality expected quality
  56165. * @param distance distance when this optimized version should be used
  56166. * @param optimizeMesh already optimized mesh
  56167. */
  56168. constructor(
  56169. /** expected quality */
  56170. quality: number,
  56171. /** distance when this optimized version should be used */
  56172. distance: number,
  56173. /** already optimized mesh */
  56174. optimizeMesh?: boolean | undefined);
  56175. }
  56176. /**
  56177. * Interface used to define a simplification task
  56178. */
  56179. export interface ISimplificationTask {
  56180. /**
  56181. * Array of settings
  56182. */
  56183. settings: Array<ISimplificationSettings>;
  56184. /**
  56185. * Simplification type
  56186. */
  56187. simplificationType: SimplificationType;
  56188. /**
  56189. * Mesh to simplify
  56190. */
  56191. mesh: Mesh;
  56192. /**
  56193. * Callback called on success
  56194. */
  56195. successCallback?: () => void;
  56196. /**
  56197. * Defines if parallel processing can be used
  56198. */
  56199. parallelProcessing: boolean;
  56200. }
  56201. /**
  56202. * Queue used to order the simplification tasks
  56203. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56204. */
  56205. export class SimplificationQueue {
  56206. private _simplificationArray;
  56207. /**
  56208. * Gets a boolean indicating that the process is still running
  56209. */
  56210. running: boolean;
  56211. /**
  56212. * Creates a new queue
  56213. */
  56214. constructor();
  56215. /**
  56216. * Adds a new simplification task
  56217. * @param task defines a task to add
  56218. */
  56219. addTask(task: ISimplificationTask): void;
  56220. /**
  56221. * Execute next task
  56222. */
  56223. executeNext(): void;
  56224. /**
  56225. * Execute a simplification task
  56226. * @param task defines the task to run
  56227. */
  56228. runSimplification(task: ISimplificationTask): void;
  56229. private getSimplifier;
  56230. }
  56231. /**
  56232. * The implemented types of simplification
  56233. * At the moment only Quadratic Error Decimation is implemented
  56234. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56235. */
  56236. export enum SimplificationType {
  56237. /** Quadratic error decimation */
  56238. QUADRATIC = 0
  56239. }
  56240. }
  56241. declare module BABYLON {
  56242. interface Scene {
  56243. /** @hidden (Backing field) */
  56244. _simplificationQueue: SimplificationQueue;
  56245. /**
  56246. * Gets or sets the simplification queue attached to the scene
  56247. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56248. */
  56249. simplificationQueue: SimplificationQueue;
  56250. }
  56251. interface Mesh {
  56252. /**
  56253. * Simplify the mesh according to the given array of settings.
  56254. * Function will return immediately and will simplify async
  56255. * @param settings a collection of simplification settings
  56256. * @param parallelProcessing should all levels calculate parallel or one after the other
  56257. * @param simplificationType the type of simplification to run
  56258. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56259. * @returns the current mesh
  56260. */
  56261. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56262. }
  56263. /**
  56264. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56265. * created in a scene
  56266. */
  56267. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56268. /**
  56269. * The component name helpfull to identify the component in the list of scene components.
  56270. */
  56271. readonly name: string;
  56272. /**
  56273. * The scene the component belongs to.
  56274. */
  56275. scene: Scene;
  56276. /**
  56277. * Creates a new instance of the component for the given scene
  56278. * @param scene Defines the scene to register the component in
  56279. */
  56280. constructor(scene: Scene);
  56281. /**
  56282. * Registers the component in a given scene
  56283. */
  56284. register(): void;
  56285. /**
  56286. * Rebuilds the elements related to this component in case of
  56287. * context lost for instance.
  56288. */
  56289. rebuild(): void;
  56290. /**
  56291. * Disposes the component and the associated ressources
  56292. */
  56293. dispose(): void;
  56294. private _beforeCameraUpdate;
  56295. }
  56296. }
  56297. declare module BABYLON {
  56298. /**
  56299. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56300. */
  56301. export interface INavigationEnginePlugin {
  56302. /**
  56303. * plugin name
  56304. */
  56305. name: string;
  56306. /**
  56307. * Creates a navigation mesh
  56308. * @param meshes array of all the geometry used to compute the navigatio mesh
  56309. * @param parameters bunch of parameters used to filter geometry
  56310. */
  56311. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56312. /**
  56313. * Create a navigation mesh debug mesh
  56314. * @param scene is where the mesh will be added
  56315. * @returns debug display mesh
  56316. */
  56317. createDebugNavMesh(scene: Scene): Mesh;
  56318. /**
  56319. * Get a navigation mesh constrained position, closest to the parameter position
  56320. * @param position world position
  56321. * @returns the closest point to position constrained by the navigation mesh
  56322. */
  56323. getClosestPoint(position: Vector3): Vector3;
  56324. /**
  56325. * Get a navigation mesh constrained position, within a particular radius
  56326. * @param position world position
  56327. * @param maxRadius the maximum distance to the constrained world position
  56328. * @returns the closest point to position constrained by the navigation mesh
  56329. */
  56330. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56331. /**
  56332. * Compute the final position from a segment made of destination-position
  56333. * @param position world position
  56334. * @param destination world position
  56335. * @returns the resulting point along the navmesh
  56336. */
  56337. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56338. /**
  56339. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56340. * @param start world position
  56341. * @param end world position
  56342. * @returns array containing world position composing the path
  56343. */
  56344. computePath(start: Vector3, end: Vector3): Vector3[];
  56345. /**
  56346. * If this plugin is supported
  56347. * @returns true if plugin is supported
  56348. */
  56349. isSupported(): boolean;
  56350. /**
  56351. * Create a new Crowd so you can add agents
  56352. * @param maxAgents the maximum agent count in the crowd
  56353. * @param maxAgentRadius the maximum radius an agent can have
  56354. * @param scene to attach the crowd to
  56355. * @returns the crowd you can add agents to
  56356. */
  56357. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56358. /**
  56359. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56360. * The queries will try to find a solution within those bounds
  56361. * default is (1,1,1)
  56362. * @param extent x,y,z value that define the extent around the queries point of reference
  56363. */
  56364. setDefaultQueryExtent(extent: Vector3): void;
  56365. /**
  56366. * Get the Bounding box extent specified by setDefaultQueryExtent
  56367. * @returns the box extent values
  56368. */
  56369. getDefaultQueryExtent(): Vector3;
  56370. /**
  56371. * Release all resources
  56372. */
  56373. dispose(): void;
  56374. }
  56375. /**
  56376. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56377. */
  56378. export interface ICrowd {
  56379. /**
  56380. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56381. * You can attach anything to that node. The node position is updated in the scene update tick.
  56382. * @param pos world position that will be constrained by the navigation mesh
  56383. * @param parameters agent parameters
  56384. * @param transform hooked to the agent that will be update by the scene
  56385. * @returns agent index
  56386. */
  56387. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56388. /**
  56389. * Returns the agent position in world space
  56390. * @param index agent index returned by addAgent
  56391. * @returns world space position
  56392. */
  56393. getAgentPosition(index: number): Vector3;
  56394. /**
  56395. * Gets the agent velocity in world space
  56396. * @param index agent index returned by addAgent
  56397. * @returns world space velocity
  56398. */
  56399. getAgentVelocity(index: number): Vector3;
  56400. /**
  56401. * remove a particular agent previously created
  56402. * @param index agent index returned by addAgent
  56403. */
  56404. removeAgent(index: number): void;
  56405. /**
  56406. * get the list of all agents attached to this crowd
  56407. * @returns list of agent indices
  56408. */
  56409. getAgents(): number[];
  56410. /**
  56411. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56412. * @param deltaTime in seconds
  56413. */
  56414. update(deltaTime: number): void;
  56415. /**
  56416. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56417. * @param index agent index returned by addAgent
  56418. * @param destination targeted world position
  56419. */
  56420. agentGoto(index: number, destination: Vector3): void;
  56421. /**
  56422. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56423. * The queries will try to find a solution within those bounds
  56424. * default is (1,1,1)
  56425. * @param extent x,y,z value that define the extent around the queries point of reference
  56426. */
  56427. setDefaultQueryExtent(extent: Vector3): void;
  56428. /**
  56429. * Get the Bounding box extent specified by setDefaultQueryExtent
  56430. * @returns the box extent values
  56431. */
  56432. getDefaultQueryExtent(): Vector3;
  56433. /**
  56434. * Release all resources
  56435. */
  56436. dispose(): void;
  56437. }
  56438. /**
  56439. * Configures an agent
  56440. */
  56441. export interface IAgentParameters {
  56442. /**
  56443. * Agent radius. [Limit: >= 0]
  56444. */
  56445. radius: number;
  56446. /**
  56447. * Agent height. [Limit: > 0]
  56448. */
  56449. height: number;
  56450. /**
  56451. * Maximum allowed acceleration. [Limit: >= 0]
  56452. */
  56453. maxAcceleration: number;
  56454. /**
  56455. * Maximum allowed speed. [Limit: >= 0]
  56456. */
  56457. maxSpeed: number;
  56458. /**
  56459. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56460. */
  56461. collisionQueryRange: number;
  56462. /**
  56463. * The path visibility optimization range. [Limit: > 0]
  56464. */
  56465. pathOptimizationRange: number;
  56466. /**
  56467. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56468. */
  56469. separationWeight: number;
  56470. }
  56471. /**
  56472. * Configures the navigation mesh creation
  56473. */
  56474. export interface INavMeshParameters {
  56475. /**
  56476. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56477. */
  56478. cs: number;
  56479. /**
  56480. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56481. */
  56482. ch: number;
  56483. /**
  56484. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56485. */
  56486. walkableSlopeAngle: number;
  56487. /**
  56488. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56489. * be considered walkable. [Limit: >= 3] [Units: vx]
  56490. */
  56491. walkableHeight: number;
  56492. /**
  56493. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56494. */
  56495. walkableClimb: number;
  56496. /**
  56497. * The distance to erode/shrink the walkable area of the heightfield away from
  56498. * obstructions. [Limit: >=0] [Units: vx]
  56499. */
  56500. walkableRadius: number;
  56501. /**
  56502. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56503. */
  56504. maxEdgeLen: number;
  56505. /**
  56506. * The maximum distance a simplfied contour's border edges should deviate
  56507. * the original raw contour. [Limit: >=0] [Units: vx]
  56508. */
  56509. maxSimplificationError: number;
  56510. /**
  56511. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56512. */
  56513. minRegionArea: number;
  56514. /**
  56515. * Any regions with a span count smaller than this value will, if possible,
  56516. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56517. */
  56518. mergeRegionArea: number;
  56519. /**
  56520. * The maximum number of vertices allowed for polygons generated during the
  56521. * contour to polygon conversion process. [Limit: >= 3]
  56522. */
  56523. maxVertsPerPoly: number;
  56524. /**
  56525. * Sets the sampling distance to use when generating the detail mesh.
  56526. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56527. */
  56528. detailSampleDist: number;
  56529. /**
  56530. * The maximum distance the detail mesh surface should deviate from heightfield
  56531. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56532. */
  56533. detailSampleMaxError: number;
  56534. }
  56535. }
  56536. declare module BABYLON {
  56537. /**
  56538. * RecastJS navigation plugin
  56539. */
  56540. export class RecastJSPlugin implements INavigationEnginePlugin {
  56541. /**
  56542. * Reference to the Recast library
  56543. */
  56544. bjsRECAST: any;
  56545. /**
  56546. * plugin name
  56547. */
  56548. name: string;
  56549. /**
  56550. * the first navmesh created. We might extend this to support multiple navmeshes
  56551. */
  56552. navMesh: any;
  56553. /**
  56554. * Initializes the recastJS plugin
  56555. * @param recastInjection can be used to inject your own recast reference
  56556. */
  56557. constructor(recastInjection?: any);
  56558. /**
  56559. * Creates a navigation mesh
  56560. * @param meshes array of all the geometry used to compute the navigatio mesh
  56561. * @param parameters bunch of parameters used to filter geometry
  56562. */
  56563. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56564. /**
  56565. * Create a navigation mesh debug mesh
  56566. * @param scene is where the mesh will be added
  56567. * @returns debug display mesh
  56568. */
  56569. createDebugNavMesh(scene: Scene): Mesh;
  56570. /**
  56571. * Get a navigation mesh constrained position, closest to the parameter position
  56572. * @param position world position
  56573. * @returns the closest point to position constrained by the navigation mesh
  56574. */
  56575. getClosestPoint(position: Vector3): Vector3;
  56576. /**
  56577. * Get a navigation mesh constrained position, within a particular radius
  56578. * @param position world position
  56579. * @param maxRadius the maximum distance to the constrained world position
  56580. * @returns the closest point to position constrained by the navigation mesh
  56581. */
  56582. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56583. /**
  56584. * Compute the final position from a segment made of destination-position
  56585. * @param position world position
  56586. * @param destination world position
  56587. * @returns the resulting point along the navmesh
  56588. */
  56589. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56590. /**
  56591. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56592. * @param start world position
  56593. * @param end world position
  56594. * @returns array containing world position composing the path
  56595. */
  56596. computePath(start: Vector3, end: Vector3): Vector3[];
  56597. /**
  56598. * Create a new Crowd so you can add agents
  56599. * @param maxAgents the maximum agent count in the crowd
  56600. * @param maxAgentRadius the maximum radius an agent can have
  56601. * @param scene to attach the crowd to
  56602. * @returns the crowd you can add agents to
  56603. */
  56604. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56605. /**
  56606. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56607. * The queries will try to find a solution within those bounds
  56608. * default is (1,1,1)
  56609. * @param extent x,y,z value that define the extent around the queries point of reference
  56610. */
  56611. setDefaultQueryExtent(extent: Vector3): void;
  56612. /**
  56613. * Get the Bounding box extent specified by setDefaultQueryExtent
  56614. * @returns the box extent values
  56615. */
  56616. getDefaultQueryExtent(): Vector3;
  56617. /**
  56618. * Disposes
  56619. */
  56620. dispose(): void;
  56621. /**
  56622. * If this plugin is supported
  56623. * @returns true if plugin is supported
  56624. */
  56625. isSupported(): boolean;
  56626. }
  56627. /**
  56628. * Recast detour crowd implementation
  56629. */
  56630. export class RecastJSCrowd implements ICrowd {
  56631. /**
  56632. * Recast/detour plugin
  56633. */
  56634. bjsRECASTPlugin: RecastJSPlugin;
  56635. /**
  56636. * Link to the detour crowd
  56637. */
  56638. recastCrowd: any;
  56639. /**
  56640. * One transform per agent
  56641. */
  56642. transforms: TransformNode[];
  56643. /**
  56644. * All agents created
  56645. */
  56646. agents: number[];
  56647. /**
  56648. * Link to the scene is kept to unregister the crowd from the scene
  56649. */
  56650. private _scene;
  56651. /**
  56652. * Observer for crowd updates
  56653. */
  56654. private _onBeforeAnimationsObserver;
  56655. /**
  56656. * Constructor
  56657. * @param plugin recastJS plugin
  56658. * @param maxAgents the maximum agent count in the crowd
  56659. * @param maxAgentRadius the maximum radius an agent can have
  56660. * @param scene to attach the crowd to
  56661. * @returns the crowd you can add agents to
  56662. */
  56663. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56664. /**
  56665. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56666. * You can attach anything to that node. The node position is updated in the scene update tick.
  56667. * @param pos world position that will be constrained by the navigation mesh
  56668. * @param parameters agent parameters
  56669. * @param transform hooked to the agent that will be update by the scene
  56670. * @returns agent index
  56671. */
  56672. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56673. /**
  56674. * Returns the agent position in world space
  56675. * @param index agent index returned by addAgent
  56676. * @returns world space position
  56677. */
  56678. getAgentPosition(index: number): Vector3;
  56679. /**
  56680. * Returns the agent velocity in world space
  56681. * @param index agent index returned by addAgent
  56682. * @returns world space velocity
  56683. */
  56684. getAgentVelocity(index: number): Vector3;
  56685. /**
  56686. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56687. * @param index agent index returned by addAgent
  56688. * @param destination targeted world position
  56689. */
  56690. agentGoto(index: number, destination: Vector3): void;
  56691. /**
  56692. * remove a particular agent previously created
  56693. * @param index agent index returned by addAgent
  56694. */
  56695. removeAgent(index: number): void;
  56696. /**
  56697. * get the list of all agents attached to this crowd
  56698. * @returns list of agent indices
  56699. */
  56700. getAgents(): number[];
  56701. /**
  56702. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56703. * @param deltaTime in seconds
  56704. */
  56705. update(deltaTime: number): void;
  56706. /**
  56707. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56708. * The queries will try to find a solution within those bounds
  56709. * default is (1,1,1)
  56710. * @param extent x,y,z value that define the extent around the queries point of reference
  56711. */
  56712. setDefaultQueryExtent(extent: Vector3): void;
  56713. /**
  56714. * Get the Bounding box extent specified by setDefaultQueryExtent
  56715. * @returns the box extent values
  56716. */
  56717. getDefaultQueryExtent(): Vector3;
  56718. /**
  56719. * Release all resources
  56720. */
  56721. dispose(): void;
  56722. }
  56723. }
  56724. declare module BABYLON {
  56725. /**
  56726. * Class used to enable access to IndexedDB
  56727. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56728. */
  56729. export class Database implements IOfflineProvider {
  56730. private _callbackManifestChecked;
  56731. private _currentSceneUrl;
  56732. private _db;
  56733. private _enableSceneOffline;
  56734. private _enableTexturesOffline;
  56735. private _manifestVersionFound;
  56736. private _mustUpdateRessources;
  56737. private _hasReachedQuota;
  56738. private _isSupported;
  56739. private _idbFactory;
  56740. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56741. private static IsUASupportingBlobStorage;
  56742. /**
  56743. * Gets a boolean indicating if Database storate is enabled (off by default)
  56744. */
  56745. static IDBStorageEnabled: boolean;
  56746. /**
  56747. * Gets a boolean indicating if scene must be saved in the database
  56748. */
  56749. readonly enableSceneOffline: boolean;
  56750. /**
  56751. * Gets a boolean indicating if textures must be saved in the database
  56752. */
  56753. readonly enableTexturesOffline: boolean;
  56754. /**
  56755. * Creates a new Database
  56756. * @param urlToScene defines the url to load the scene
  56757. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56758. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56759. */
  56760. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56761. private static _ParseURL;
  56762. private static _ReturnFullUrlLocation;
  56763. private _checkManifestFile;
  56764. /**
  56765. * Open the database and make it available
  56766. * @param successCallback defines the callback to call on success
  56767. * @param errorCallback defines the callback to call on error
  56768. */
  56769. open(successCallback: () => void, errorCallback: () => void): void;
  56770. /**
  56771. * Loads an image from the database
  56772. * @param url defines the url to load from
  56773. * @param image defines the target DOM image
  56774. */
  56775. loadImage(url: string, image: HTMLImageElement): void;
  56776. private _loadImageFromDBAsync;
  56777. private _saveImageIntoDBAsync;
  56778. private _checkVersionFromDB;
  56779. private _loadVersionFromDBAsync;
  56780. private _saveVersionIntoDBAsync;
  56781. /**
  56782. * Loads a file from database
  56783. * @param url defines the URL to load from
  56784. * @param sceneLoaded defines a callback to call on success
  56785. * @param progressCallBack defines a callback to call when progress changed
  56786. * @param errorCallback defines a callback to call on error
  56787. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56788. */
  56789. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56790. private _loadFileAsync;
  56791. private _saveFileAsync;
  56792. /**
  56793. * Validates if xhr data is correct
  56794. * @param xhr defines the request to validate
  56795. * @param dataType defines the expected data type
  56796. * @returns true if data is correct
  56797. */
  56798. private static _ValidateXHRData;
  56799. }
  56800. }
  56801. declare module BABYLON {
  56802. /** @hidden */
  56803. export var gpuUpdateParticlesPixelShader: {
  56804. name: string;
  56805. shader: string;
  56806. };
  56807. }
  56808. declare module BABYLON {
  56809. /** @hidden */
  56810. export var gpuUpdateParticlesVertexShader: {
  56811. name: string;
  56812. shader: string;
  56813. };
  56814. }
  56815. declare module BABYLON {
  56816. /** @hidden */
  56817. export var clipPlaneFragmentDeclaration2: {
  56818. name: string;
  56819. shader: string;
  56820. };
  56821. }
  56822. declare module BABYLON {
  56823. /** @hidden */
  56824. export var gpuRenderParticlesPixelShader: {
  56825. name: string;
  56826. shader: string;
  56827. };
  56828. }
  56829. declare module BABYLON {
  56830. /** @hidden */
  56831. export var clipPlaneVertexDeclaration2: {
  56832. name: string;
  56833. shader: string;
  56834. };
  56835. }
  56836. declare module BABYLON {
  56837. /** @hidden */
  56838. export var gpuRenderParticlesVertexShader: {
  56839. name: string;
  56840. shader: string;
  56841. };
  56842. }
  56843. declare module BABYLON {
  56844. /**
  56845. * This represents a GPU particle system in Babylon
  56846. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56847. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56848. */
  56849. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56850. /**
  56851. * The layer mask we are rendering the particles through.
  56852. */
  56853. layerMask: number;
  56854. private _capacity;
  56855. private _activeCount;
  56856. private _currentActiveCount;
  56857. private _accumulatedCount;
  56858. private _renderEffect;
  56859. private _updateEffect;
  56860. private _buffer0;
  56861. private _buffer1;
  56862. private _spriteBuffer;
  56863. private _updateVAO;
  56864. private _renderVAO;
  56865. private _targetIndex;
  56866. private _sourceBuffer;
  56867. private _targetBuffer;
  56868. private _engine;
  56869. private _currentRenderId;
  56870. private _started;
  56871. private _stopped;
  56872. private _timeDelta;
  56873. private _randomTexture;
  56874. private _randomTexture2;
  56875. private _attributesStrideSize;
  56876. private _updateEffectOptions;
  56877. private _randomTextureSize;
  56878. private _actualFrame;
  56879. private readonly _rawTextureWidth;
  56880. /**
  56881. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56882. */
  56883. static readonly IsSupported: boolean;
  56884. /**
  56885. * An event triggered when the system is disposed.
  56886. */
  56887. onDisposeObservable: Observable<GPUParticleSystem>;
  56888. /**
  56889. * Gets the maximum number of particles active at the same time.
  56890. * @returns The max number of active particles.
  56891. */
  56892. getCapacity(): number;
  56893. /**
  56894. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56895. * to override the particles.
  56896. */
  56897. forceDepthWrite: boolean;
  56898. /**
  56899. * Gets or set the number of active particles
  56900. */
  56901. activeParticleCount: number;
  56902. private _preWarmDone;
  56903. /**
  56904. * Is this system ready to be used/rendered
  56905. * @return true if the system is ready
  56906. */
  56907. isReady(): boolean;
  56908. /**
  56909. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56910. * @returns True if it has been started, otherwise false.
  56911. */
  56912. isStarted(): boolean;
  56913. /**
  56914. * Starts the particle system and begins to emit
  56915. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56916. */
  56917. start(delay?: number): void;
  56918. /**
  56919. * Stops the particle system.
  56920. */
  56921. stop(): void;
  56922. /**
  56923. * Remove all active particles
  56924. */
  56925. reset(): void;
  56926. /**
  56927. * Returns the string "GPUParticleSystem"
  56928. * @returns a string containing the class name
  56929. */
  56930. getClassName(): string;
  56931. private _colorGradientsTexture;
  56932. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56933. /**
  56934. * Adds a new color gradient
  56935. * @param gradient defines the gradient to use (between 0 and 1)
  56936. * @param color1 defines the color to affect to the specified gradient
  56937. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56938. * @returns the current particle system
  56939. */
  56940. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56941. /**
  56942. * Remove a specific color gradient
  56943. * @param gradient defines the gradient to remove
  56944. * @returns the current particle system
  56945. */
  56946. removeColorGradient(gradient: number): GPUParticleSystem;
  56947. private _angularSpeedGradientsTexture;
  56948. private _sizeGradientsTexture;
  56949. private _velocityGradientsTexture;
  56950. private _limitVelocityGradientsTexture;
  56951. private _dragGradientsTexture;
  56952. private _addFactorGradient;
  56953. /**
  56954. * Adds a new size gradient
  56955. * @param gradient defines the gradient to use (between 0 and 1)
  56956. * @param factor defines the size factor to affect to the specified gradient
  56957. * @returns the current particle system
  56958. */
  56959. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56960. /**
  56961. * Remove a specific size gradient
  56962. * @param gradient defines the gradient to remove
  56963. * @returns the current particle system
  56964. */
  56965. removeSizeGradient(gradient: number): GPUParticleSystem;
  56966. /**
  56967. * Adds a new angular speed gradient
  56968. * @param gradient defines the gradient to use (between 0 and 1)
  56969. * @param factor defines the angular speed to affect to the specified gradient
  56970. * @returns the current particle system
  56971. */
  56972. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56973. /**
  56974. * Remove a specific angular speed gradient
  56975. * @param gradient defines the gradient to remove
  56976. * @returns the current particle system
  56977. */
  56978. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56979. /**
  56980. * Adds a new velocity gradient
  56981. * @param gradient defines the gradient to use (between 0 and 1)
  56982. * @param factor defines the velocity to affect to the specified gradient
  56983. * @returns the current particle system
  56984. */
  56985. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56986. /**
  56987. * Remove a specific velocity gradient
  56988. * @param gradient defines the gradient to remove
  56989. * @returns the current particle system
  56990. */
  56991. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56992. /**
  56993. * Adds a new limit velocity gradient
  56994. * @param gradient defines the gradient to use (between 0 and 1)
  56995. * @param factor defines the limit velocity value to affect to the specified gradient
  56996. * @returns the current particle system
  56997. */
  56998. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56999. /**
  57000. * Remove a specific limit velocity gradient
  57001. * @param gradient defines the gradient to remove
  57002. * @returns the current particle system
  57003. */
  57004. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57005. /**
  57006. * Adds a new drag gradient
  57007. * @param gradient defines the gradient to use (between 0 and 1)
  57008. * @param factor defines the drag value to affect to the specified gradient
  57009. * @returns the current particle system
  57010. */
  57011. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57012. /**
  57013. * Remove a specific drag gradient
  57014. * @param gradient defines the gradient to remove
  57015. * @returns the current particle system
  57016. */
  57017. removeDragGradient(gradient: number): GPUParticleSystem;
  57018. /**
  57019. * Not supported by GPUParticleSystem
  57020. * @param gradient defines the gradient to use (between 0 and 1)
  57021. * @param factor defines the emit rate value to affect to the specified gradient
  57022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57023. * @returns the current particle system
  57024. */
  57025. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57026. /**
  57027. * Not supported by GPUParticleSystem
  57028. * @param gradient defines the gradient to remove
  57029. * @returns the current particle system
  57030. */
  57031. removeEmitRateGradient(gradient: number): IParticleSystem;
  57032. /**
  57033. * Not supported by GPUParticleSystem
  57034. * @param gradient defines the gradient to use (between 0 and 1)
  57035. * @param factor defines the start size value to affect to the specified gradient
  57036. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57037. * @returns the current particle system
  57038. */
  57039. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57040. /**
  57041. * Not supported by GPUParticleSystem
  57042. * @param gradient defines the gradient to remove
  57043. * @returns the current particle system
  57044. */
  57045. removeStartSizeGradient(gradient: number): IParticleSystem;
  57046. /**
  57047. * Not supported by GPUParticleSystem
  57048. * @param gradient defines the gradient to use (between 0 and 1)
  57049. * @param min defines the color remap minimal range
  57050. * @param max defines the color remap maximal range
  57051. * @returns the current particle system
  57052. */
  57053. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57054. /**
  57055. * Not supported by GPUParticleSystem
  57056. * @param gradient defines the gradient to remove
  57057. * @returns the current particle system
  57058. */
  57059. removeColorRemapGradient(): IParticleSystem;
  57060. /**
  57061. * Not supported by GPUParticleSystem
  57062. * @param gradient defines the gradient to use (between 0 and 1)
  57063. * @param min defines the alpha remap minimal range
  57064. * @param max defines the alpha remap maximal range
  57065. * @returns the current particle system
  57066. */
  57067. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57068. /**
  57069. * Not supported by GPUParticleSystem
  57070. * @param gradient defines the gradient to remove
  57071. * @returns the current particle system
  57072. */
  57073. removeAlphaRemapGradient(): IParticleSystem;
  57074. /**
  57075. * Not supported by GPUParticleSystem
  57076. * @param gradient defines the gradient to use (between 0 and 1)
  57077. * @param color defines the color to affect to the specified gradient
  57078. * @returns the current particle system
  57079. */
  57080. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57081. /**
  57082. * Not supported by GPUParticleSystem
  57083. * @param gradient defines the gradient to remove
  57084. * @returns the current particle system
  57085. */
  57086. removeRampGradient(): IParticleSystem;
  57087. /**
  57088. * Not supported by GPUParticleSystem
  57089. * @returns the list of ramp gradients
  57090. */
  57091. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57092. /**
  57093. * Not supported by GPUParticleSystem
  57094. * Gets or sets a boolean indicating that ramp gradients must be used
  57095. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57096. */
  57097. useRampGradients: boolean;
  57098. /**
  57099. * Not supported by GPUParticleSystem
  57100. * @param gradient defines the gradient to use (between 0 and 1)
  57101. * @param factor defines the life time factor to affect to the specified gradient
  57102. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57103. * @returns the current particle system
  57104. */
  57105. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57106. /**
  57107. * Not supported by GPUParticleSystem
  57108. * @param gradient defines the gradient to remove
  57109. * @returns the current particle system
  57110. */
  57111. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57112. /**
  57113. * Instantiates a GPU particle system.
  57114. * 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.
  57115. * @param name The name of the particle system
  57116. * @param options The options used to create the system
  57117. * @param scene The scene the particle system belongs to
  57118. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57119. */
  57120. constructor(name: string, options: Partial<{
  57121. capacity: number;
  57122. randomTextureSize: number;
  57123. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57124. protected _reset(): void;
  57125. private _createUpdateVAO;
  57126. private _createRenderVAO;
  57127. private _initialize;
  57128. /** @hidden */
  57129. _recreateUpdateEffect(): void;
  57130. /** @hidden */
  57131. _recreateRenderEffect(): void;
  57132. /**
  57133. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57134. * @param preWarm defines if we are in the pre-warmimg phase
  57135. */
  57136. animate(preWarm?: boolean): void;
  57137. private _createFactorGradientTexture;
  57138. private _createSizeGradientTexture;
  57139. private _createAngularSpeedGradientTexture;
  57140. private _createVelocityGradientTexture;
  57141. private _createLimitVelocityGradientTexture;
  57142. private _createDragGradientTexture;
  57143. private _createColorGradientTexture;
  57144. /**
  57145. * Renders the particle system in its current state
  57146. * @param preWarm defines if the system should only update the particles but not render them
  57147. * @returns the current number of particles
  57148. */
  57149. render(preWarm?: boolean): number;
  57150. /**
  57151. * Rebuilds the particle system
  57152. */
  57153. rebuild(): void;
  57154. private _releaseBuffers;
  57155. private _releaseVAOs;
  57156. /**
  57157. * Disposes the particle system and free the associated resources
  57158. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57159. */
  57160. dispose(disposeTexture?: boolean): void;
  57161. /**
  57162. * Clones the particle system.
  57163. * @param name The name of the cloned object
  57164. * @param newEmitter The new emitter to use
  57165. * @returns the cloned particle system
  57166. */
  57167. clone(name: string, newEmitter: any): GPUParticleSystem;
  57168. /**
  57169. * Serializes the particle system to a JSON object.
  57170. * @returns the JSON object
  57171. */
  57172. serialize(): any;
  57173. /**
  57174. * Parses a JSON object to create a GPU particle system.
  57175. * @param parsedParticleSystem The JSON object to parse
  57176. * @param scene The scene to create the particle system in
  57177. * @param rootUrl The root url to use to load external dependencies like texture
  57178. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57179. * @returns the parsed GPU particle system
  57180. */
  57181. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57182. }
  57183. }
  57184. declare module BABYLON {
  57185. /**
  57186. * Represents a set of particle systems working together to create a specific effect
  57187. */
  57188. export class ParticleSystemSet implements IDisposable {
  57189. private _emitterCreationOptions;
  57190. private _emitterNode;
  57191. /**
  57192. * Gets the particle system list
  57193. */
  57194. systems: IParticleSystem[];
  57195. /**
  57196. * Gets the emitter node used with this set
  57197. */
  57198. readonly emitterNode: Nullable<TransformNode>;
  57199. /**
  57200. * Creates a new emitter mesh as a sphere
  57201. * @param options defines the options used to create the sphere
  57202. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57203. * @param scene defines the hosting scene
  57204. */
  57205. setEmitterAsSphere(options: {
  57206. diameter: number;
  57207. segments: number;
  57208. color: Color3;
  57209. }, renderingGroupId: number, scene: Scene): void;
  57210. /**
  57211. * Starts all particle systems of the set
  57212. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57213. */
  57214. start(emitter?: AbstractMesh): void;
  57215. /**
  57216. * Release all associated resources
  57217. */
  57218. dispose(): void;
  57219. /**
  57220. * Serialize the set into a JSON compatible object
  57221. * @returns a JSON compatible representation of the set
  57222. */
  57223. serialize(): any;
  57224. /**
  57225. * Parse a new ParticleSystemSet from a serialized source
  57226. * @param data defines a JSON compatible representation of the set
  57227. * @param scene defines the hosting scene
  57228. * @param gpu defines if we want GPU particles or CPU particles
  57229. * @returns a new ParticleSystemSet
  57230. */
  57231. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57232. }
  57233. }
  57234. declare module BABYLON {
  57235. /**
  57236. * This class is made for on one-liner static method to help creating particle system set.
  57237. */
  57238. export class ParticleHelper {
  57239. /**
  57240. * Gets or sets base Assets URL
  57241. */
  57242. static BaseAssetsUrl: string;
  57243. /**
  57244. * Create a default particle system that you can tweak
  57245. * @param emitter defines the emitter to use
  57246. * @param capacity defines the system capacity (default is 500 particles)
  57247. * @param scene defines the hosting scene
  57248. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57249. * @returns the new Particle system
  57250. */
  57251. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57252. /**
  57253. * This is the main static method (one-liner) of this helper to create different particle systems
  57254. * @param type This string represents the type to the particle system to create
  57255. * @param scene The scene where the particle system should live
  57256. * @param gpu If the system will use gpu
  57257. * @returns the ParticleSystemSet created
  57258. */
  57259. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57260. /**
  57261. * Static function used to export a particle system to a ParticleSystemSet variable.
  57262. * Please note that the emitter shape is not exported
  57263. * @param systems defines the particle systems to export
  57264. * @returns the created particle system set
  57265. */
  57266. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57267. }
  57268. }
  57269. declare module BABYLON {
  57270. interface Engine {
  57271. /**
  57272. * Create an effect to use with particle systems.
  57273. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57274. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57275. * @param uniformsNames defines a list of attribute names
  57276. * @param samplers defines an array of string used to represent textures
  57277. * @param defines defines the string containing the defines to use to compile the shaders
  57278. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57279. * @param onCompiled defines a function to call when the effect creation is successful
  57280. * @param onError defines a function to call when the effect creation has failed
  57281. * @returns the new Effect
  57282. */
  57283. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57284. }
  57285. interface Mesh {
  57286. /**
  57287. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57288. * @returns an array of IParticleSystem
  57289. */
  57290. getEmittedParticleSystems(): IParticleSystem[];
  57291. /**
  57292. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57293. * @returns an array of IParticleSystem
  57294. */
  57295. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57296. }
  57297. /**
  57298. * @hidden
  57299. */
  57300. export var _IDoNeedToBeInTheBuild: number;
  57301. }
  57302. declare module BABYLON {
  57303. interface Scene {
  57304. /** @hidden (Backing field) */
  57305. _physicsEngine: Nullable<IPhysicsEngine>;
  57306. /**
  57307. * Gets the current physics engine
  57308. * @returns a IPhysicsEngine or null if none attached
  57309. */
  57310. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57311. /**
  57312. * Enables physics to the current scene
  57313. * @param gravity defines the scene's gravity for the physics engine
  57314. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57315. * @return a boolean indicating if the physics engine was initialized
  57316. */
  57317. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57318. /**
  57319. * Disables and disposes the physics engine associated with the scene
  57320. */
  57321. disablePhysicsEngine(): void;
  57322. /**
  57323. * Gets a boolean indicating if there is an active physics engine
  57324. * @returns a boolean indicating if there is an active physics engine
  57325. */
  57326. isPhysicsEnabled(): boolean;
  57327. /**
  57328. * Deletes a physics compound impostor
  57329. * @param compound defines the compound to delete
  57330. */
  57331. deleteCompoundImpostor(compound: any): void;
  57332. /**
  57333. * An event triggered when physic simulation is about to be run
  57334. */
  57335. onBeforePhysicsObservable: Observable<Scene>;
  57336. /**
  57337. * An event triggered when physic simulation has been done
  57338. */
  57339. onAfterPhysicsObservable: Observable<Scene>;
  57340. }
  57341. interface AbstractMesh {
  57342. /** @hidden */
  57343. _physicsImpostor: Nullable<PhysicsImpostor>;
  57344. /**
  57345. * Gets or sets impostor used for physic simulation
  57346. * @see http://doc.babylonjs.com/features/physics_engine
  57347. */
  57348. physicsImpostor: Nullable<PhysicsImpostor>;
  57349. /**
  57350. * Gets the current physics impostor
  57351. * @see http://doc.babylonjs.com/features/physics_engine
  57352. * @returns a physics impostor or null
  57353. */
  57354. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57355. /** Apply a physic impulse to the mesh
  57356. * @param force defines the force to apply
  57357. * @param contactPoint defines where to apply the force
  57358. * @returns the current mesh
  57359. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57360. */
  57361. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57362. /**
  57363. * Creates a physic joint between two meshes
  57364. * @param otherMesh defines the other mesh to use
  57365. * @param pivot1 defines the pivot to use on this mesh
  57366. * @param pivot2 defines the pivot to use on the other mesh
  57367. * @param options defines additional options (can be plugin dependent)
  57368. * @returns the current mesh
  57369. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57370. */
  57371. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57372. /** @hidden */
  57373. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57374. }
  57375. /**
  57376. * Defines the physics engine scene component responsible to manage a physics engine
  57377. */
  57378. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57379. /**
  57380. * The component name helpful to identify the component in the list of scene components.
  57381. */
  57382. readonly name: string;
  57383. /**
  57384. * The scene the component belongs to.
  57385. */
  57386. scene: Scene;
  57387. /**
  57388. * Creates a new instance of the component for the given scene
  57389. * @param scene Defines the scene to register the component in
  57390. */
  57391. constructor(scene: Scene);
  57392. /**
  57393. * Registers the component in a given scene
  57394. */
  57395. register(): void;
  57396. /**
  57397. * Rebuilds the elements related to this component in case of
  57398. * context lost for instance.
  57399. */
  57400. rebuild(): void;
  57401. /**
  57402. * Disposes the component and the associated ressources
  57403. */
  57404. dispose(): void;
  57405. }
  57406. }
  57407. declare module BABYLON {
  57408. /**
  57409. * A helper for physics simulations
  57410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57411. */
  57412. export class PhysicsHelper {
  57413. private _scene;
  57414. private _physicsEngine;
  57415. /**
  57416. * Initializes the Physics helper
  57417. * @param scene Babylon.js scene
  57418. */
  57419. constructor(scene: Scene);
  57420. /**
  57421. * Applies a radial explosion impulse
  57422. * @param origin the origin of the explosion
  57423. * @param radiusOrEventOptions the radius or the options of radial explosion
  57424. * @param strength the explosion strength
  57425. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57426. * @returns A physics radial explosion event, or null
  57427. */
  57428. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57429. /**
  57430. * Applies a radial explosion force
  57431. * @param origin the origin of the explosion
  57432. * @param radiusOrEventOptions the radius or the options of radial explosion
  57433. * @param strength the explosion strength
  57434. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57435. * @returns A physics radial explosion event, or null
  57436. */
  57437. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57438. /**
  57439. * Creates a gravitational field
  57440. * @param origin the origin of the explosion
  57441. * @param radiusOrEventOptions the radius or the options of radial explosion
  57442. * @param strength the explosion strength
  57443. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57444. * @returns A physics gravitational field event, or null
  57445. */
  57446. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57447. /**
  57448. * Creates a physics updraft event
  57449. * @param origin the origin of the updraft
  57450. * @param radiusOrEventOptions the radius or the options of the updraft
  57451. * @param strength the strength of the updraft
  57452. * @param height the height of the updraft
  57453. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57454. * @returns A physics updraft event, or null
  57455. */
  57456. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57457. /**
  57458. * Creates a physics vortex event
  57459. * @param origin the of the vortex
  57460. * @param radiusOrEventOptions the radius or the options of the vortex
  57461. * @param strength the strength of the vortex
  57462. * @param height the height of the vortex
  57463. * @returns a Physics vortex event, or null
  57464. * A physics vortex event or null
  57465. */
  57466. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57467. }
  57468. /**
  57469. * Represents a physics radial explosion event
  57470. */
  57471. class PhysicsRadialExplosionEvent {
  57472. private _scene;
  57473. private _options;
  57474. private _sphere;
  57475. private _dataFetched;
  57476. /**
  57477. * Initializes a radial explosioin event
  57478. * @param _scene BabylonJS scene
  57479. * @param _options The options for the vortex event
  57480. */
  57481. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57482. /**
  57483. * Returns the data related to the radial explosion event (sphere).
  57484. * @returns The radial explosion event data
  57485. */
  57486. getData(): PhysicsRadialExplosionEventData;
  57487. /**
  57488. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57489. * @param impostor A physics imposter
  57490. * @param origin the origin of the explosion
  57491. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57492. */
  57493. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57494. /**
  57495. * Triggers affecterd impostors callbacks
  57496. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57497. */
  57498. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57499. /**
  57500. * Disposes the sphere.
  57501. * @param force Specifies if the sphere should be disposed by force
  57502. */
  57503. dispose(force?: boolean): void;
  57504. /*** Helpers ***/
  57505. private _prepareSphere;
  57506. private _intersectsWithSphere;
  57507. }
  57508. /**
  57509. * Represents a gravitational field event
  57510. */
  57511. class PhysicsGravitationalFieldEvent {
  57512. private _physicsHelper;
  57513. private _scene;
  57514. private _origin;
  57515. private _options;
  57516. private _tickCallback;
  57517. private _sphere;
  57518. private _dataFetched;
  57519. /**
  57520. * Initializes the physics gravitational field event
  57521. * @param _physicsHelper A physics helper
  57522. * @param _scene BabylonJS scene
  57523. * @param _origin The origin position of the gravitational field event
  57524. * @param _options The options for the vortex event
  57525. */
  57526. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57527. /**
  57528. * Returns the data related to the gravitational field event (sphere).
  57529. * @returns A gravitational field event
  57530. */
  57531. getData(): PhysicsGravitationalFieldEventData;
  57532. /**
  57533. * Enables the gravitational field.
  57534. */
  57535. enable(): void;
  57536. /**
  57537. * Disables the gravitational field.
  57538. */
  57539. disable(): void;
  57540. /**
  57541. * Disposes the sphere.
  57542. * @param force The force to dispose from the gravitational field event
  57543. */
  57544. dispose(force?: boolean): void;
  57545. private _tick;
  57546. }
  57547. /**
  57548. * Represents a physics updraft event
  57549. */
  57550. class PhysicsUpdraftEvent {
  57551. private _scene;
  57552. private _origin;
  57553. private _options;
  57554. private _physicsEngine;
  57555. private _originTop;
  57556. private _originDirection;
  57557. private _tickCallback;
  57558. private _cylinder;
  57559. private _cylinderPosition;
  57560. private _dataFetched;
  57561. /**
  57562. * Initializes the physics updraft event
  57563. * @param _scene BabylonJS scene
  57564. * @param _origin The origin position of the updraft
  57565. * @param _options The options for the updraft event
  57566. */
  57567. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57568. /**
  57569. * Returns the data related to the updraft event (cylinder).
  57570. * @returns A physics updraft event
  57571. */
  57572. getData(): PhysicsUpdraftEventData;
  57573. /**
  57574. * Enables the updraft.
  57575. */
  57576. enable(): void;
  57577. /**
  57578. * Disables the updraft.
  57579. */
  57580. disable(): void;
  57581. /**
  57582. * Disposes the cylinder.
  57583. * @param force Specifies if the updraft should be disposed by force
  57584. */
  57585. dispose(force?: boolean): void;
  57586. private getImpostorHitData;
  57587. private _tick;
  57588. /*** Helpers ***/
  57589. private _prepareCylinder;
  57590. private _intersectsWithCylinder;
  57591. }
  57592. /**
  57593. * Represents a physics vortex event
  57594. */
  57595. class PhysicsVortexEvent {
  57596. private _scene;
  57597. private _origin;
  57598. private _options;
  57599. private _physicsEngine;
  57600. private _originTop;
  57601. private _tickCallback;
  57602. private _cylinder;
  57603. private _cylinderPosition;
  57604. private _dataFetched;
  57605. /**
  57606. * Initializes the physics vortex event
  57607. * @param _scene The BabylonJS scene
  57608. * @param _origin The origin position of the vortex
  57609. * @param _options The options for the vortex event
  57610. */
  57611. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57612. /**
  57613. * Returns the data related to the vortex event (cylinder).
  57614. * @returns The physics vortex event data
  57615. */
  57616. getData(): PhysicsVortexEventData;
  57617. /**
  57618. * Enables the vortex.
  57619. */
  57620. enable(): void;
  57621. /**
  57622. * Disables the cortex.
  57623. */
  57624. disable(): void;
  57625. /**
  57626. * Disposes the sphere.
  57627. * @param force
  57628. */
  57629. dispose(force?: boolean): void;
  57630. private getImpostorHitData;
  57631. private _tick;
  57632. /*** Helpers ***/
  57633. private _prepareCylinder;
  57634. private _intersectsWithCylinder;
  57635. }
  57636. /**
  57637. * Options fot the radial explosion event
  57638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57639. */
  57640. export class PhysicsRadialExplosionEventOptions {
  57641. /**
  57642. * The radius of the sphere for the radial explosion.
  57643. */
  57644. radius: number;
  57645. /**
  57646. * The strenth of the explosion.
  57647. */
  57648. strength: number;
  57649. /**
  57650. * The strenght of the force in correspondence to the distance of the affected object
  57651. */
  57652. falloff: PhysicsRadialImpulseFalloff;
  57653. /**
  57654. * Sphere options for the radial explosion.
  57655. */
  57656. sphere: {
  57657. segments: number;
  57658. diameter: number;
  57659. };
  57660. /**
  57661. * Sphere options for the radial explosion.
  57662. */
  57663. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57664. }
  57665. /**
  57666. * Options fot the updraft event
  57667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57668. */
  57669. export class PhysicsUpdraftEventOptions {
  57670. /**
  57671. * The radius of the cylinder for the vortex
  57672. */
  57673. radius: number;
  57674. /**
  57675. * The strenth of the updraft.
  57676. */
  57677. strength: number;
  57678. /**
  57679. * The height of the cylinder for the updraft.
  57680. */
  57681. height: number;
  57682. /**
  57683. * The mode for the the updraft.
  57684. */
  57685. updraftMode: PhysicsUpdraftMode;
  57686. }
  57687. /**
  57688. * Options fot the vortex event
  57689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57690. */
  57691. export class PhysicsVortexEventOptions {
  57692. /**
  57693. * The radius of the cylinder for the vortex
  57694. */
  57695. radius: number;
  57696. /**
  57697. * The strenth of the vortex.
  57698. */
  57699. strength: number;
  57700. /**
  57701. * The height of the cylinder for the vortex.
  57702. */
  57703. height: number;
  57704. /**
  57705. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57706. */
  57707. centripetalForceThreshold: number;
  57708. /**
  57709. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57710. */
  57711. centripetalForceMultiplier: number;
  57712. /**
  57713. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57714. */
  57715. centrifugalForceMultiplier: number;
  57716. /**
  57717. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57718. */
  57719. updraftForceMultiplier: number;
  57720. }
  57721. /**
  57722. * The strenght of the force in correspondence to the distance of the affected object
  57723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57724. */
  57725. export enum PhysicsRadialImpulseFalloff {
  57726. /** Defines that impulse is constant in strength across it's whole radius */
  57727. Constant = 0,
  57728. /** Defines that impulse gets weaker if it's further from the origin */
  57729. Linear = 1
  57730. }
  57731. /**
  57732. * The strength of the force in correspondence to the distance of the affected object
  57733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57734. */
  57735. export enum PhysicsUpdraftMode {
  57736. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57737. Center = 0,
  57738. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57739. Perpendicular = 1
  57740. }
  57741. /**
  57742. * Interface for a physics hit data
  57743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57744. */
  57745. export interface PhysicsHitData {
  57746. /**
  57747. * The force applied at the contact point
  57748. */
  57749. force: Vector3;
  57750. /**
  57751. * The contact point
  57752. */
  57753. contactPoint: Vector3;
  57754. /**
  57755. * The distance from the origin to the contact point
  57756. */
  57757. distanceFromOrigin: number;
  57758. }
  57759. /**
  57760. * Interface for radial explosion event data
  57761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57762. */
  57763. export interface PhysicsRadialExplosionEventData {
  57764. /**
  57765. * A sphere used for the radial explosion event
  57766. */
  57767. sphere: Mesh;
  57768. }
  57769. /**
  57770. * Interface for gravitational field event data
  57771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57772. */
  57773. export interface PhysicsGravitationalFieldEventData {
  57774. /**
  57775. * A sphere mesh used for the gravitational field event
  57776. */
  57777. sphere: Mesh;
  57778. }
  57779. /**
  57780. * Interface for updraft event data
  57781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57782. */
  57783. export interface PhysicsUpdraftEventData {
  57784. /**
  57785. * A cylinder used for the updraft event
  57786. */
  57787. cylinder: Mesh;
  57788. }
  57789. /**
  57790. * Interface for vortex event data
  57791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57792. */
  57793. export interface PhysicsVortexEventData {
  57794. /**
  57795. * A cylinder used for the vortex event
  57796. */
  57797. cylinder: Mesh;
  57798. }
  57799. /**
  57800. * Interface for an affected physics impostor
  57801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57802. */
  57803. export interface PhysicsAffectedImpostorWithData {
  57804. /**
  57805. * The impostor affected by the effect
  57806. */
  57807. impostor: PhysicsImpostor;
  57808. /**
  57809. * The data about the hit/horce from the explosion
  57810. */
  57811. hitData: PhysicsHitData;
  57812. }
  57813. }
  57814. declare module BABYLON {
  57815. /** @hidden */
  57816. export var blackAndWhitePixelShader: {
  57817. name: string;
  57818. shader: string;
  57819. };
  57820. }
  57821. declare module BABYLON {
  57822. /**
  57823. * Post process used to render in black and white
  57824. */
  57825. export class BlackAndWhitePostProcess extends PostProcess {
  57826. /**
  57827. * Linear about to convert he result to black and white (default: 1)
  57828. */
  57829. degree: number;
  57830. /**
  57831. * Creates a black and white post process
  57832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57833. * @param name The name of the effect.
  57834. * @param options The required width/height ratio to downsize to before computing the render pass.
  57835. * @param camera The camera to apply the render pass to.
  57836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57837. * @param engine The engine which the post process will be applied. (default: current engine)
  57838. * @param reusable If the post process can be reused on the same frame. (default: false)
  57839. */
  57840. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57841. }
  57842. }
  57843. declare module BABYLON {
  57844. /**
  57845. * This represents a set of one or more post processes in Babylon.
  57846. * A post process can be used to apply a shader to a texture after it is rendered.
  57847. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57848. */
  57849. export class PostProcessRenderEffect {
  57850. private _postProcesses;
  57851. private _getPostProcesses;
  57852. private _singleInstance;
  57853. private _cameras;
  57854. private _indicesForCamera;
  57855. /**
  57856. * Name of the effect
  57857. * @hidden
  57858. */
  57859. _name: string;
  57860. /**
  57861. * Instantiates a post process render effect.
  57862. * A post process can be used to apply a shader to a texture after it is rendered.
  57863. * @param engine The engine the effect is tied to
  57864. * @param name The name of the effect
  57865. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57866. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57867. */
  57868. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57869. /**
  57870. * Checks if all the post processes in the effect are supported.
  57871. */
  57872. readonly isSupported: boolean;
  57873. /**
  57874. * Updates the current state of the effect
  57875. * @hidden
  57876. */
  57877. _update(): void;
  57878. /**
  57879. * Attaches the effect on cameras
  57880. * @param cameras The camera to attach to.
  57881. * @hidden
  57882. */
  57883. _attachCameras(cameras: Camera): void;
  57884. /**
  57885. * Attaches the effect on cameras
  57886. * @param cameras The camera to attach to.
  57887. * @hidden
  57888. */
  57889. _attachCameras(cameras: Camera[]): void;
  57890. /**
  57891. * Detaches the effect on cameras
  57892. * @param cameras The camera to detatch from.
  57893. * @hidden
  57894. */
  57895. _detachCameras(cameras: Camera): void;
  57896. /**
  57897. * Detatches the effect on cameras
  57898. * @param cameras The camera to detatch from.
  57899. * @hidden
  57900. */
  57901. _detachCameras(cameras: Camera[]): void;
  57902. /**
  57903. * Enables the effect on given cameras
  57904. * @param cameras The camera to enable.
  57905. * @hidden
  57906. */
  57907. _enable(cameras: Camera): void;
  57908. /**
  57909. * Enables the effect on given cameras
  57910. * @param cameras The camera to enable.
  57911. * @hidden
  57912. */
  57913. _enable(cameras: Nullable<Camera[]>): void;
  57914. /**
  57915. * Disables the effect on the given cameras
  57916. * @param cameras The camera to disable.
  57917. * @hidden
  57918. */
  57919. _disable(cameras: Camera): void;
  57920. /**
  57921. * Disables the effect on the given cameras
  57922. * @param cameras The camera to disable.
  57923. * @hidden
  57924. */
  57925. _disable(cameras: Nullable<Camera[]>): void;
  57926. /**
  57927. * Gets a list of the post processes contained in the effect.
  57928. * @param camera The camera to get the post processes on.
  57929. * @returns The list of the post processes in the effect.
  57930. */
  57931. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57932. }
  57933. }
  57934. declare module BABYLON {
  57935. /** @hidden */
  57936. export var extractHighlightsPixelShader: {
  57937. name: string;
  57938. shader: string;
  57939. };
  57940. }
  57941. declare module BABYLON {
  57942. /**
  57943. * 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.
  57944. */
  57945. export class ExtractHighlightsPostProcess extends PostProcess {
  57946. /**
  57947. * The luminance threshold, pixels below this value will be set to black.
  57948. */
  57949. threshold: number;
  57950. /** @hidden */
  57951. _exposure: number;
  57952. /**
  57953. * Post process which has the input texture to be used when performing highlight extraction
  57954. * @hidden
  57955. */
  57956. _inputPostProcess: Nullable<PostProcess>;
  57957. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57958. }
  57959. }
  57960. declare module BABYLON {
  57961. /** @hidden */
  57962. export var bloomMergePixelShader: {
  57963. name: string;
  57964. shader: string;
  57965. };
  57966. }
  57967. declare module BABYLON {
  57968. /**
  57969. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57970. */
  57971. export class BloomMergePostProcess extends PostProcess {
  57972. /** Weight of the bloom to be added to the original input. */
  57973. weight: number;
  57974. /**
  57975. * Creates a new instance of @see BloomMergePostProcess
  57976. * @param name The name of the effect.
  57977. * @param originalFromInput Post process which's input will be used for the merge.
  57978. * @param blurred Blurred highlights post process which's output will be used.
  57979. * @param weight Weight of the bloom to be added to the original input.
  57980. * @param options The required width/height ratio to downsize to before computing the render pass.
  57981. * @param camera The camera to apply the render pass to.
  57982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57983. * @param engine The engine which the post process will be applied. (default: current engine)
  57984. * @param reusable If the post process can be reused on the same frame. (default: false)
  57985. * @param textureType Type of textures used when performing the post process. (default: 0)
  57986. * @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)
  57987. */
  57988. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57989. /** Weight of the bloom to be added to the original input. */
  57990. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57991. }
  57992. }
  57993. declare module BABYLON {
  57994. /**
  57995. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57996. */
  57997. export class BloomEffect extends PostProcessRenderEffect {
  57998. private bloomScale;
  57999. /**
  58000. * @hidden Internal
  58001. */
  58002. _effects: Array<PostProcess>;
  58003. /**
  58004. * @hidden Internal
  58005. */
  58006. _downscale: ExtractHighlightsPostProcess;
  58007. private _blurX;
  58008. private _blurY;
  58009. private _merge;
  58010. /**
  58011. * The luminance threshold to find bright areas of the image to bloom.
  58012. */
  58013. threshold: number;
  58014. /**
  58015. * The strength of the bloom.
  58016. */
  58017. weight: number;
  58018. /**
  58019. * Specifies the size of the bloom blur kernel, relative to the final output size
  58020. */
  58021. kernel: number;
  58022. /**
  58023. * Creates a new instance of @see BloomEffect
  58024. * @param scene The scene the effect belongs to.
  58025. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58026. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58027. * @param bloomWeight The the strength of bloom.
  58028. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58029. * @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)
  58030. */
  58031. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58032. /**
  58033. * Disposes each of the internal effects for a given camera.
  58034. * @param camera The camera to dispose the effect on.
  58035. */
  58036. disposeEffects(camera: Camera): void;
  58037. /**
  58038. * @hidden Internal
  58039. */
  58040. _updateEffects(): void;
  58041. /**
  58042. * Internal
  58043. * @returns if all the contained post processes are ready.
  58044. * @hidden
  58045. */
  58046. _isReady(): boolean;
  58047. }
  58048. }
  58049. declare module BABYLON {
  58050. /** @hidden */
  58051. export var chromaticAberrationPixelShader: {
  58052. name: string;
  58053. shader: string;
  58054. };
  58055. }
  58056. declare module BABYLON {
  58057. /**
  58058. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58059. */
  58060. export class ChromaticAberrationPostProcess extends PostProcess {
  58061. /**
  58062. * The amount of seperation of rgb channels (default: 30)
  58063. */
  58064. aberrationAmount: number;
  58065. /**
  58066. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58067. */
  58068. radialIntensity: number;
  58069. /**
  58070. * 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))
  58071. */
  58072. direction: Vector2;
  58073. /**
  58074. * 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))
  58075. */
  58076. centerPosition: Vector2;
  58077. /**
  58078. * Creates a new instance ChromaticAberrationPostProcess
  58079. * @param name The name of the effect.
  58080. * @param screenWidth The width of the screen to apply the effect on.
  58081. * @param screenHeight The height of the screen to apply the effect on.
  58082. * @param options The required width/height ratio to downsize to before computing the render pass.
  58083. * @param camera The camera to apply the render pass to.
  58084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58085. * @param engine The engine which the post process will be applied. (default: current engine)
  58086. * @param reusable If the post process can be reused on the same frame. (default: false)
  58087. * @param textureType Type of textures used when performing the post process. (default: 0)
  58088. * @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)
  58089. */
  58090. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58091. }
  58092. }
  58093. declare module BABYLON {
  58094. /** @hidden */
  58095. export var circleOfConfusionPixelShader: {
  58096. name: string;
  58097. shader: string;
  58098. };
  58099. }
  58100. declare module BABYLON {
  58101. /**
  58102. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58103. */
  58104. export class CircleOfConfusionPostProcess extends PostProcess {
  58105. /**
  58106. * 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.
  58107. */
  58108. lensSize: number;
  58109. /**
  58110. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58111. */
  58112. fStop: number;
  58113. /**
  58114. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58115. */
  58116. focusDistance: number;
  58117. /**
  58118. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58119. */
  58120. focalLength: number;
  58121. private _depthTexture;
  58122. /**
  58123. * Creates a new instance CircleOfConfusionPostProcess
  58124. * @param name The name of the effect.
  58125. * @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.
  58126. * @param options The required width/height ratio to downsize to before computing the render pass.
  58127. * @param camera The camera to apply the render pass to.
  58128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58129. * @param engine The engine which the post process will be applied. (default: current engine)
  58130. * @param reusable If the post process can be reused on the same frame. (default: false)
  58131. * @param textureType Type of textures used when performing the post process. (default: 0)
  58132. * @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)
  58133. */
  58134. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58135. /**
  58136. * 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.
  58137. */
  58138. depthTexture: RenderTargetTexture;
  58139. }
  58140. }
  58141. declare module BABYLON {
  58142. /** @hidden */
  58143. export var colorCorrectionPixelShader: {
  58144. name: string;
  58145. shader: string;
  58146. };
  58147. }
  58148. declare module BABYLON {
  58149. /**
  58150. *
  58151. * This post-process allows the modification of rendered colors by using
  58152. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58153. *
  58154. * The object needs to be provided an url to a texture containing the color
  58155. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58156. * Use an image editing software to tweak the LUT to match your needs.
  58157. *
  58158. * For an example of a color LUT, see here:
  58159. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58160. * For explanations on color grading, see here:
  58161. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58162. *
  58163. */
  58164. export class ColorCorrectionPostProcess extends PostProcess {
  58165. private _colorTableTexture;
  58166. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58167. }
  58168. }
  58169. declare module BABYLON {
  58170. /** @hidden */
  58171. export var convolutionPixelShader: {
  58172. name: string;
  58173. shader: string;
  58174. };
  58175. }
  58176. declare module BABYLON {
  58177. /**
  58178. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58179. * input texture to perform effects such as edge detection or sharpening
  58180. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58181. */
  58182. export class ConvolutionPostProcess extends PostProcess {
  58183. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58184. kernel: number[];
  58185. /**
  58186. * Creates a new instance ConvolutionPostProcess
  58187. * @param name The name of the effect.
  58188. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58189. * @param options The required width/height ratio to downsize to before computing the render pass.
  58190. * @param camera The camera to apply the render pass to.
  58191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58192. * @param engine The engine which the post process will be applied. (default: current engine)
  58193. * @param reusable If the post process can be reused on the same frame. (default: false)
  58194. * @param textureType Type of textures used when performing the post process. (default: 0)
  58195. */
  58196. constructor(name: string,
  58197. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58198. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58199. /**
  58200. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58201. */
  58202. static EdgeDetect0Kernel: number[];
  58203. /**
  58204. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58205. */
  58206. static EdgeDetect1Kernel: number[];
  58207. /**
  58208. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58209. */
  58210. static EdgeDetect2Kernel: number[];
  58211. /**
  58212. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58213. */
  58214. static SharpenKernel: number[];
  58215. /**
  58216. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58217. */
  58218. static EmbossKernel: number[];
  58219. /**
  58220. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58221. */
  58222. static GaussianKernel: number[];
  58223. }
  58224. }
  58225. declare module BABYLON {
  58226. /**
  58227. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58228. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58229. * based on samples that have a large difference in distance than the center pixel.
  58230. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58231. */
  58232. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58233. direction: Vector2;
  58234. /**
  58235. * Creates a new instance CircleOfConfusionPostProcess
  58236. * @param name The name of the effect.
  58237. * @param scene The scene the effect belongs to.
  58238. * @param direction The direction the blur should be applied.
  58239. * @param kernel The size of the kernel used to blur.
  58240. * @param options The required width/height ratio to downsize to before computing the render pass.
  58241. * @param camera The camera to apply the render pass to.
  58242. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58243. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58245. * @param engine The engine which the post process will be applied. (default: current engine)
  58246. * @param reusable If the post process can be reused on the same frame. (default: false)
  58247. * @param textureType Type of textures used when performing the post process. (default: 0)
  58248. * @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)
  58249. */
  58250. 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);
  58251. }
  58252. }
  58253. declare module BABYLON {
  58254. /** @hidden */
  58255. export var depthOfFieldMergePixelShader: {
  58256. name: string;
  58257. shader: string;
  58258. };
  58259. }
  58260. declare module BABYLON {
  58261. /**
  58262. * Options to be set when merging outputs from the default pipeline.
  58263. */
  58264. export class DepthOfFieldMergePostProcessOptions {
  58265. /**
  58266. * The original image to merge on top of
  58267. */
  58268. originalFromInput: PostProcess;
  58269. /**
  58270. * Parameters to perform the merge of the depth of field effect
  58271. */
  58272. depthOfField?: {
  58273. circleOfConfusion: PostProcess;
  58274. blurSteps: Array<PostProcess>;
  58275. };
  58276. /**
  58277. * Parameters to perform the merge of bloom effect
  58278. */
  58279. bloom?: {
  58280. blurred: PostProcess;
  58281. weight: number;
  58282. };
  58283. }
  58284. /**
  58285. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58286. */
  58287. export class DepthOfFieldMergePostProcess extends PostProcess {
  58288. private blurSteps;
  58289. /**
  58290. * Creates a new instance of DepthOfFieldMergePostProcess
  58291. * @param name The name of the effect.
  58292. * @param originalFromInput Post process which's input will be used for the merge.
  58293. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58294. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58295. * @param options The required width/height ratio to downsize to before computing the render pass.
  58296. * @param camera The camera to apply the render pass to.
  58297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58298. * @param engine The engine which the post process will be applied. (default: current engine)
  58299. * @param reusable If the post process can be reused on the same frame. (default: false)
  58300. * @param textureType Type of textures used when performing the post process. (default: 0)
  58301. * @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)
  58302. */
  58303. 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);
  58304. /**
  58305. * Updates the effect with the current post process compile time values and recompiles the shader.
  58306. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58307. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58308. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58309. * @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
  58310. * @param onCompiled Called when the shader has been compiled.
  58311. * @param onError Called if there is an error when compiling a shader.
  58312. */
  58313. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58314. }
  58315. }
  58316. declare module BABYLON {
  58317. /**
  58318. * Specifies the level of max blur that should be applied when using the depth of field effect
  58319. */
  58320. export enum DepthOfFieldEffectBlurLevel {
  58321. /**
  58322. * Subtle blur
  58323. */
  58324. Low = 0,
  58325. /**
  58326. * Medium blur
  58327. */
  58328. Medium = 1,
  58329. /**
  58330. * Large blur
  58331. */
  58332. High = 2
  58333. }
  58334. /**
  58335. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58336. */
  58337. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58338. private _circleOfConfusion;
  58339. /**
  58340. * @hidden Internal, blurs from high to low
  58341. */
  58342. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58343. private _depthOfFieldBlurY;
  58344. private _dofMerge;
  58345. /**
  58346. * @hidden Internal post processes in depth of field effect
  58347. */
  58348. _effects: Array<PostProcess>;
  58349. /**
  58350. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58351. */
  58352. focalLength: number;
  58353. /**
  58354. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58355. */
  58356. fStop: number;
  58357. /**
  58358. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58359. */
  58360. focusDistance: number;
  58361. /**
  58362. * 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.
  58363. */
  58364. lensSize: number;
  58365. /**
  58366. * Creates a new instance DepthOfFieldEffect
  58367. * @param scene The scene the effect belongs to.
  58368. * @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.
  58369. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58370. * @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)
  58371. */
  58372. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58373. /**
  58374. * Get the current class name of the current effet
  58375. * @returns "DepthOfFieldEffect"
  58376. */
  58377. getClassName(): string;
  58378. /**
  58379. * 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.
  58380. */
  58381. depthTexture: RenderTargetTexture;
  58382. /**
  58383. * Disposes each of the internal effects for a given camera.
  58384. * @param camera The camera to dispose the effect on.
  58385. */
  58386. disposeEffects(camera: Camera): void;
  58387. /**
  58388. * @hidden Internal
  58389. */
  58390. _updateEffects(): void;
  58391. /**
  58392. * Internal
  58393. * @returns if all the contained post processes are ready.
  58394. * @hidden
  58395. */
  58396. _isReady(): boolean;
  58397. }
  58398. }
  58399. declare module BABYLON {
  58400. /** @hidden */
  58401. export var displayPassPixelShader: {
  58402. name: string;
  58403. shader: string;
  58404. };
  58405. }
  58406. declare module BABYLON {
  58407. /**
  58408. * DisplayPassPostProcess which produces an output the same as it's input
  58409. */
  58410. export class DisplayPassPostProcess extends PostProcess {
  58411. /**
  58412. * Creates the DisplayPassPostProcess
  58413. * @param name The name of the effect.
  58414. * @param options The required width/height ratio to downsize to before computing the render pass.
  58415. * @param camera The camera to apply the render pass to.
  58416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58417. * @param engine The engine which the post process will be applied. (default: current engine)
  58418. * @param reusable If the post process can be reused on the same frame. (default: false)
  58419. */
  58420. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58421. }
  58422. }
  58423. declare module BABYLON {
  58424. /** @hidden */
  58425. export var filterPixelShader: {
  58426. name: string;
  58427. shader: string;
  58428. };
  58429. }
  58430. declare module BABYLON {
  58431. /**
  58432. * Applies a kernel filter to the image
  58433. */
  58434. export class FilterPostProcess extends PostProcess {
  58435. /** The matrix to be applied to the image */
  58436. kernelMatrix: Matrix;
  58437. /**
  58438. *
  58439. * @param name The name of the effect.
  58440. * @param kernelMatrix The matrix to be applied to the image
  58441. * @param options The required width/height ratio to downsize to before computing the render pass.
  58442. * @param camera The camera to apply the render pass to.
  58443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58444. * @param engine The engine which the post process will be applied. (default: current engine)
  58445. * @param reusable If the post process can be reused on the same frame. (default: false)
  58446. */
  58447. constructor(name: string,
  58448. /** The matrix to be applied to the image */
  58449. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58450. }
  58451. }
  58452. declare module BABYLON {
  58453. /** @hidden */
  58454. export var fxaaPixelShader: {
  58455. name: string;
  58456. shader: string;
  58457. };
  58458. }
  58459. declare module BABYLON {
  58460. /** @hidden */
  58461. export var fxaaVertexShader: {
  58462. name: string;
  58463. shader: string;
  58464. };
  58465. }
  58466. declare module BABYLON {
  58467. /**
  58468. * Fxaa post process
  58469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58470. */
  58471. export class FxaaPostProcess extends PostProcess {
  58472. /** @hidden */
  58473. texelWidth: number;
  58474. /** @hidden */
  58475. texelHeight: number;
  58476. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58477. private _getDefines;
  58478. }
  58479. }
  58480. declare module BABYLON {
  58481. /** @hidden */
  58482. export var grainPixelShader: {
  58483. name: string;
  58484. shader: string;
  58485. };
  58486. }
  58487. declare module BABYLON {
  58488. /**
  58489. * The GrainPostProcess adds noise to the image at mid luminance levels
  58490. */
  58491. export class GrainPostProcess extends PostProcess {
  58492. /**
  58493. * The intensity of the grain added (default: 30)
  58494. */
  58495. intensity: number;
  58496. /**
  58497. * If the grain should be randomized on every frame
  58498. */
  58499. animated: boolean;
  58500. /**
  58501. * Creates a new instance of @see GrainPostProcess
  58502. * @param name The name of the effect.
  58503. * @param options The required width/height ratio to downsize to before computing the render pass.
  58504. * @param camera The camera to apply the render pass to.
  58505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58506. * @param engine The engine which the post process will be applied. (default: current engine)
  58507. * @param reusable If the post process can be reused on the same frame. (default: false)
  58508. * @param textureType Type of textures used when performing the post process. (default: 0)
  58509. * @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)
  58510. */
  58511. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58512. }
  58513. }
  58514. declare module BABYLON {
  58515. /** @hidden */
  58516. export var highlightsPixelShader: {
  58517. name: string;
  58518. shader: string;
  58519. };
  58520. }
  58521. declare module BABYLON {
  58522. /**
  58523. * Extracts highlights from the image
  58524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58525. */
  58526. export class HighlightsPostProcess extends PostProcess {
  58527. /**
  58528. * Extracts highlights from the image
  58529. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58530. * @param name The name of the effect.
  58531. * @param options The required width/height ratio to downsize to before computing the render pass.
  58532. * @param camera The camera to apply the render pass to.
  58533. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58534. * @param engine The engine which the post process will be applied. (default: current engine)
  58535. * @param reusable If the post process can be reused on the same frame. (default: false)
  58536. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58537. */
  58538. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /** @hidden */
  58543. export var mrtFragmentDeclaration: {
  58544. name: string;
  58545. shader: string;
  58546. };
  58547. }
  58548. declare module BABYLON {
  58549. /** @hidden */
  58550. export var geometryPixelShader: {
  58551. name: string;
  58552. shader: string;
  58553. };
  58554. }
  58555. declare module BABYLON {
  58556. /** @hidden */
  58557. export var geometryVertexShader: {
  58558. name: string;
  58559. shader: string;
  58560. };
  58561. }
  58562. declare module BABYLON {
  58563. /** @hidden */
  58564. interface ISavedTransformationMatrix {
  58565. world: Matrix;
  58566. viewProjection: Matrix;
  58567. }
  58568. /**
  58569. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58570. */
  58571. export class GeometryBufferRenderer {
  58572. /**
  58573. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58574. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58575. */
  58576. static readonly POSITION_TEXTURE_TYPE: number;
  58577. /**
  58578. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58579. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58580. */
  58581. static readonly VELOCITY_TEXTURE_TYPE: number;
  58582. /**
  58583. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58584. * in order to compute objects velocities when enableVelocity is set to "true"
  58585. * @hidden
  58586. */
  58587. _previousTransformationMatrices: {
  58588. [index: number]: ISavedTransformationMatrix;
  58589. };
  58590. /**
  58591. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58592. * in order to compute objects velocities when enableVelocity is set to "true"
  58593. * @hidden
  58594. */
  58595. _previousBonesTransformationMatrices: {
  58596. [index: number]: Float32Array;
  58597. };
  58598. /**
  58599. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58600. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58601. */
  58602. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58603. private _scene;
  58604. private _multiRenderTarget;
  58605. private _ratio;
  58606. private _enablePosition;
  58607. private _enableVelocity;
  58608. private _positionIndex;
  58609. private _velocityIndex;
  58610. protected _effect: Effect;
  58611. protected _cachedDefines: string;
  58612. /**
  58613. * Set the render list (meshes to be rendered) used in the G buffer.
  58614. */
  58615. renderList: Mesh[];
  58616. /**
  58617. * Gets wether or not G buffer are supported by the running hardware.
  58618. * This requires draw buffer supports
  58619. */
  58620. readonly isSupported: boolean;
  58621. /**
  58622. * Returns the index of the given texture type in the G-Buffer textures array
  58623. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58624. * @returns the index of the given texture type in the G-Buffer textures array
  58625. */
  58626. getTextureIndex(textureType: number): number;
  58627. /**
  58628. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58629. */
  58630. /**
  58631. * Sets whether or not objects positions are enabled for the G buffer.
  58632. */
  58633. enablePosition: boolean;
  58634. /**
  58635. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58636. */
  58637. /**
  58638. * Sets wether or not objects velocities are enabled for the G buffer.
  58639. */
  58640. enableVelocity: boolean;
  58641. /**
  58642. * Gets the scene associated with the buffer.
  58643. */
  58644. readonly scene: Scene;
  58645. /**
  58646. * Gets the ratio used by the buffer during its creation.
  58647. * How big is the buffer related to the main canvas.
  58648. */
  58649. readonly ratio: number;
  58650. /** @hidden */
  58651. static _SceneComponentInitialization: (scene: Scene) => void;
  58652. /**
  58653. * Creates a new G Buffer for the scene
  58654. * @param scene The scene the buffer belongs to
  58655. * @param ratio How big is the buffer related to the main canvas.
  58656. */
  58657. constructor(scene: Scene, ratio?: number);
  58658. /**
  58659. * Checks wether everything is ready to render a submesh to the G buffer.
  58660. * @param subMesh the submesh to check readiness for
  58661. * @param useInstances is the mesh drawn using instance or not
  58662. * @returns true if ready otherwise false
  58663. */
  58664. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58665. /**
  58666. * Gets the current underlying G Buffer.
  58667. * @returns the buffer
  58668. */
  58669. getGBuffer(): MultiRenderTarget;
  58670. /**
  58671. * Gets the number of samples used to render the buffer (anti aliasing).
  58672. */
  58673. /**
  58674. * Sets the number of samples used to render the buffer (anti aliasing).
  58675. */
  58676. samples: number;
  58677. /**
  58678. * Disposes the renderer and frees up associated resources.
  58679. */
  58680. dispose(): void;
  58681. protected _createRenderTargets(): void;
  58682. private _copyBonesTransformationMatrices;
  58683. }
  58684. }
  58685. declare module BABYLON {
  58686. interface Scene {
  58687. /** @hidden (Backing field) */
  58688. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58689. /**
  58690. * Gets or Sets the current geometry buffer associated to the scene.
  58691. */
  58692. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58693. /**
  58694. * Enables a GeometryBufferRender and associates it with the scene
  58695. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58696. * @returns the GeometryBufferRenderer
  58697. */
  58698. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58699. /**
  58700. * Disables the GeometryBufferRender associated with the scene
  58701. */
  58702. disableGeometryBufferRenderer(): void;
  58703. }
  58704. /**
  58705. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58706. * in several rendering techniques.
  58707. */
  58708. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58709. /**
  58710. * The component name helpful to identify the component in the list of scene components.
  58711. */
  58712. readonly name: string;
  58713. /**
  58714. * The scene the component belongs to.
  58715. */
  58716. scene: Scene;
  58717. /**
  58718. * Creates a new instance of the component for the given scene
  58719. * @param scene Defines the scene to register the component in
  58720. */
  58721. constructor(scene: Scene);
  58722. /**
  58723. * Registers the component in a given scene
  58724. */
  58725. register(): void;
  58726. /**
  58727. * Rebuilds the elements related to this component in case of
  58728. * context lost for instance.
  58729. */
  58730. rebuild(): void;
  58731. /**
  58732. * Disposes the component and the associated ressources
  58733. */
  58734. dispose(): void;
  58735. private _gatherRenderTargets;
  58736. }
  58737. }
  58738. declare module BABYLON {
  58739. /** @hidden */
  58740. export var motionBlurPixelShader: {
  58741. name: string;
  58742. shader: string;
  58743. };
  58744. }
  58745. declare module BABYLON {
  58746. /**
  58747. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58748. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58749. * As an example, all you have to do is to create the post-process:
  58750. * var mb = new BABYLON.MotionBlurPostProcess(
  58751. * 'mb', // The name of the effect.
  58752. * scene, // The scene containing the objects to blur according to their velocity.
  58753. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58754. * camera // The camera to apply the render pass to.
  58755. * );
  58756. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58757. */
  58758. export class MotionBlurPostProcess extends PostProcess {
  58759. /**
  58760. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58761. */
  58762. motionStrength: number;
  58763. /**
  58764. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58765. */
  58766. /**
  58767. * Sets the number of iterations to be used for motion blur quality
  58768. */
  58769. motionBlurSamples: number;
  58770. private _motionBlurSamples;
  58771. private _geometryBufferRenderer;
  58772. /**
  58773. * Creates a new instance MotionBlurPostProcess
  58774. * @param name The name of the effect.
  58775. * @param scene The scene containing the objects to blur according to their velocity.
  58776. * @param options The required width/height ratio to downsize to before computing the render pass.
  58777. * @param camera The camera to apply the render pass to.
  58778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58779. * @param engine The engine which the post process will be applied. (default: current engine)
  58780. * @param reusable If the post process can be reused on the same frame. (default: false)
  58781. * @param textureType Type of textures used when performing the post process. (default: 0)
  58782. * @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)
  58783. */
  58784. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58785. /**
  58786. * Excludes the given skinned mesh from computing bones velocities.
  58787. * 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.
  58788. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58789. */
  58790. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58791. /**
  58792. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58793. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58794. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58795. */
  58796. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58797. /**
  58798. * Disposes the post process.
  58799. * @param camera The camera to dispose the post process on.
  58800. */
  58801. dispose(camera?: Camera): void;
  58802. }
  58803. }
  58804. declare module BABYLON {
  58805. /** @hidden */
  58806. export var refractionPixelShader: {
  58807. name: string;
  58808. shader: string;
  58809. };
  58810. }
  58811. declare module BABYLON {
  58812. /**
  58813. * Post process which applies a refractin texture
  58814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58815. */
  58816. export class RefractionPostProcess extends PostProcess {
  58817. /** the base color of the refraction (used to taint the rendering) */
  58818. color: Color3;
  58819. /** simulated refraction depth */
  58820. depth: number;
  58821. /** the coefficient of the base color (0 to remove base color tainting) */
  58822. colorLevel: number;
  58823. private _refTexture;
  58824. private _ownRefractionTexture;
  58825. /**
  58826. * Gets or sets the refraction texture
  58827. * Please note that you are responsible for disposing the texture if you set it manually
  58828. */
  58829. refractionTexture: Texture;
  58830. /**
  58831. * Initializes the RefractionPostProcess
  58832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58833. * @param name The name of the effect.
  58834. * @param refractionTextureUrl Url of the refraction texture to use
  58835. * @param color the base color of the refraction (used to taint the rendering)
  58836. * @param depth simulated refraction depth
  58837. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58838. * @param camera The camera to apply the render pass to.
  58839. * @param options The required width/height ratio to downsize to before computing the render pass.
  58840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58841. * @param engine The engine which the post process will be applied. (default: current engine)
  58842. * @param reusable If the post process can be reused on the same frame. (default: false)
  58843. */
  58844. constructor(name: string, refractionTextureUrl: string,
  58845. /** the base color of the refraction (used to taint the rendering) */
  58846. color: Color3,
  58847. /** simulated refraction depth */
  58848. depth: number,
  58849. /** the coefficient of the base color (0 to remove base color tainting) */
  58850. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58851. /**
  58852. * Disposes of the post process
  58853. * @param camera Camera to dispose post process on
  58854. */
  58855. dispose(camera: Camera): void;
  58856. }
  58857. }
  58858. declare module BABYLON {
  58859. /** @hidden */
  58860. export var sharpenPixelShader: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module BABYLON {
  58866. /**
  58867. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58868. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58869. */
  58870. export class SharpenPostProcess extends PostProcess {
  58871. /**
  58872. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58873. */
  58874. colorAmount: number;
  58875. /**
  58876. * How much sharpness should be applied (default: 0.3)
  58877. */
  58878. edgeAmount: number;
  58879. /**
  58880. * Creates a new instance ConvolutionPostProcess
  58881. * @param name The name of the effect.
  58882. * @param options The required width/height ratio to downsize to before computing the render pass.
  58883. * @param camera The camera to apply the render pass to.
  58884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58885. * @param engine The engine which the post process will be applied. (default: current engine)
  58886. * @param reusable If the post process can be reused on the same frame. (default: false)
  58887. * @param textureType Type of textures used when performing the post process. (default: 0)
  58888. * @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)
  58889. */
  58890. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58891. }
  58892. }
  58893. declare module BABYLON {
  58894. /**
  58895. * PostProcessRenderPipeline
  58896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58897. */
  58898. export class PostProcessRenderPipeline {
  58899. private engine;
  58900. private _renderEffects;
  58901. private _renderEffectsForIsolatedPass;
  58902. /**
  58903. * List of inspectable custom properties (used by the Inspector)
  58904. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58905. */
  58906. inspectableCustomProperties: IInspectable[];
  58907. /**
  58908. * @hidden
  58909. */
  58910. protected _cameras: Camera[];
  58911. /** @hidden */
  58912. _name: string;
  58913. /**
  58914. * Gets pipeline name
  58915. */
  58916. readonly name: string;
  58917. /**
  58918. * Initializes a PostProcessRenderPipeline
  58919. * @param engine engine to add the pipeline to
  58920. * @param name name of the pipeline
  58921. */
  58922. constructor(engine: Engine, name: string);
  58923. /**
  58924. * Gets the class name
  58925. * @returns "PostProcessRenderPipeline"
  58926. */
  58927. getClassName(): string;
  58928. /**
  58929. * If all the render effects in the pipeline are supported
  58930. */
  58931. readonly isSupported: boolean;
  58932. /**
  58933. * Adds an effect to the pipeline
  58934. * @param renderEffect the effect to add
  58935. */
  58936. addEffect(renderEffect: PostProcessRenderEffect): void;
  58937. /** @hidden */
  58938. _rebuild(): void;
  58939. /** @hidden */
  58940. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58941. /** @hidden */
  58942. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58943. /** @hidden */
  58944. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58945. /** @hidden */
  58946. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58947. /** @hidden */
  58948. _attachCameras(cameras: Camera, unique: boolean): void;
  58949. /** @hidden */
  58950. _attachCameras(cameras: Camera[], unique: boolean): void;
  58951. /** @hidden */
  58952. _detachCameras(cameras: Camera): void;
  58953. /** @hidden */
  58954. _detachCameras(cameras: Nullable<Camera[]>): void;
  58955. /** @hidden */
  58956. _update(): void;
  58957. /** @hidden */
  58958. _reset(): void;
  58959. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58960. /**
  58961. * Disposes of the pipeline
  58962. */
  58963. dispose(): void;
  58964. }
  58965. }
  58966. declare module BABYLON {
  58967. /**
  58968. * PostProcessRenderPipelineManager class
  58969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58970. */
  58971. export class PostProcessRenderPipelineManager {
  58972. private _renderPipelines;
  58973. /**
  58974. * Initializes a PostProcessRenderPipelineManager
  58975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58976. */
  58977. constructor();
  58978. /**
  58979. * Gets the list of supported render pipelines
  58980. */
  58981. readonly supportedPipelines: PostProcessRenderPipeline[];
  58982. /**
  58983. * Adds a pipeline to the manager
  58984. * @param renderPipeline The pipeline to add
  58985. */
  58986. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58987. /**
  58988. * Attaches a camera to the pipeline
  58989. * @param renderPipelineName The name of the pipeline to attach to
  58990. * @param cameras the camera to attach
  58991. * @param unique if the camera can be attached multiple times to the pipeline
  58992. */
  58993. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58994. /**
  58995. * Detaches a camera from the pipeline
  58996. * @param renderPipelineName The name of the pipeline to detach from
  58997. * @param cameras the camera to detach
  58998. */
  58999. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59000. /**
  59001. * Enables an effect by name on a pipeline
  59002. * @param renderPipelineName the name of the pipeline to enable the effect in
  59003. * @param renderEffectName the name of the effect to enable
  59004. * @param cameras the cameras that the effect should be enabled on
  59005. */
  59006. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59007. /**
  59008. * Disables an effect by name on a pipeline
  59009. * @param renderPipelineName the name of the pipeline to disable the effect in
  59010. * @param renderEffectName the name of the effect to disable
  59011. * @param cameras the cameras that the effect should be disabled on
  59012. */
  59013. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59014. /**
  59015. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59016. */
  59017. update(): void;
  59018. /** @hidden */
  59019. _rebuild(): void;
  59020. /**
  59021. * Disposes of the manager and pipelines
  59022. */
  59023. dispose(): void;
  59024. }
  59025. }
  59026. declare module BABYLON {
  59027. interface Scene {
  59028. /** @hidden (Backing field) */
  59029. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59030. /**
  59031. * Gets the postprocess render pipeline manager
  59032. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59033. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59034. */
  59035. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59036. }
  59037. /**
  59038. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59039. */
  59040. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59041. /**
  59042. * The component name helpfull to identify the component in the list of scene components.
  59043. */
  59044. readonly name: string;
  59045. /**
  59046. * The scene the component belongs to.
  59047. */
  59048. scene: Scene;
  59049. /**
  59050. * Creates a new instance of the component for the given scene
  59051. * @param scene Defines the scene to register the component in
  59052. */
  59053. constructor(scene: Scene);
  59054. /**
  59055. * Registers the component in a given scene
  59056. */
  59057. register(): void;
  59058. /**
  59059. * Rebuilds the elements related to this component in case of
  59060. * context lost for instance.
  59061. */
  59062. rebuild(): void;
  59063. /**
  59064. * Disposes the component and the associated ressources
  59065. */
  59066. dispose(): void;
  59067. private _gatherRenderTargets;
  59068. }
  59069. }
  59070. declare module BABYLON {
  59071. /**
  59072. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59073. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59074. */
  59075. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59076. private _scene;
  59077. private _camerasToBeAttached;
  59078. /**
  59079. * ID of the sharpen post process,
  59080. */
  59081. private readonly SharpenPostProcessId;
  59082. /**
  59083. * @ignore
  59084. * ID of the image processing post process;
  59085. */
  59086. readonly ImageProcessingPostProcessId: string;
  59087. /**
  59088. * @ignore
  59089. * ID of the Fast Approximate Anti-Aliasing post process;
  59090. */
  59091. readonly FxaaPostProcessId: string;
  59092. /**
  59093. * ID of the chromatic aberration post process,
  59094. */
  59095. private readonly ChromaticAberrationPostProcessId;
  59096. /**
  59097. * ID of the grain post process
  59098. */
  59099. private readonly GrainPostProcessId;
  59100. /**
  59101. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59102. */
  59103. sharpen: SharpenPostProcess;
  59104. private _sharpenEffect;
  59105. private bloom;
  59106. /**
  59107. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59108. */
  59109. depthOfField: DepthOfFieldEffect;
  59110. /**
  59111. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59112. */
  59113. fxaa: FxaaPostProcess;
  59114. /**
  59115. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59116. */
  59117. imageProcessing: ImageProcessingPostProcess;
  59118. /**
  59119. * Chromatic aberration post process which will shift rgb colors in the image
  59120. */
  59121. chromaticAberration: ChromaticAberrationPostProcess;
  59122. private _chromaticAberrationEffect;
  59123. /**
  59124. * Grain post process which add noise to the image
  59125. */
  59126. grain: GrainPostProcess;
  59127. private _grainEffect;
  59128. /**
  59129. * Glow post process which adds a glow to emissive areas of the image
  59130. */
  59131. private _glowLayer;
  59132. /**
  59133. * Animations which can be used to tweak settings over a period of time
  59134. */
  59135. animations: Animation[];
  59136. private _imageProcessingConfigurationObserver;
  59137. private _sharpenEnabled;
  59138. private _bloomEnabled;
  59139. private _depthOfFieldEnabled;
  59140. private _depthOfFieldBlurLevel;
  59141. private _fxaaEnabled;
  59142. private _imageProcessingEnabled;
  59143. private _defaultPipelineTextureType;
  59144. private _bloomScale;
  59145. private _chromaticAberrationEnabled;
  59146. private _grainEnabled;
  59147. private _buildAllowed;
  59148. /**
  59149. * Gets active scene
  59150. */
  59151. readonly scene: Scene;
  59152. /**
  59153. * Enable or disable the sharpen process from the pipeline
  59154. */
  59155. sharpenEnabled: boolean;
  59156. private _resizeObserver;
  59157. private _hardwareScaleLevel;
  59158. private _bloomKernel;
  59159. /**
  59160. * Specifies the size of the bloom blur kernel, relative to the final output size
  59161. */
  59162. bloomKernel: number;
  59163. /**
  59164. * Specifies the weight of the bloom in the final rendering
  59165. */
  59166. private _bloomWeight;
  59167. /**
  59168. * Specifies the luma threshold for the area that will be blurred by the bloom
  59169. */
  59170. private _bloomThreshold;
  59171. private _hdr;
  59172. /**
  59173. * The strength of the bloom.
  59174. */
  59175. bloomWeight: number;
  59176. /**
  59177. * The strength of the bloom.
  59178. */
  59179. bloomThreshold: number;
  59180. /**
  59181. * The scale of the bloom, lower value will provide better performance.
  59182. */
  59183. bloomScale: number;
  59184. /**
  59185. * Enable or disable the bloom from the pipeline
  59186. */
  59187. bloomEnabled: boolean;
  59188. private _rebuildBloom;
  59189. /**
  59190. * If the depth of field is enabled.
  59191. */
  59192. depthOfFieldEnabled: boolean;
  59193. /**
  59194. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59195. */
  59196. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59197. /**
  59198. * If the anti aliasing is enabled.
  59199. */
  59200. fxaaEnabled: boolean;
  59201. private _samples;
  59202. /**
  59203. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59204. */
  59205. samples: number;
  59206. /**
  59207. * If image processing is enabled.
  59208. */
  59209. imageProcessingEnabled: boolean;
  59210. /**
  59211. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59212. */
  59213. glowLayerEnabled: boolean;
  59214. /**
  59215. * Gets the glow layer (or null if not defined)
  59216. */
  59217. readonly glowLayer: Nullable<GlowLayer>;
  59218. /**
  59219. * Enable or disable the chromaticAberration process from the pipeline
  59220. */
  59221. chromaticAberrationEnabled: boolean;
  59222. /**
  59223. * Enable or disable the grain process from the pipeline
  59224. */
  59225. grainEnabled: boolean;
  59226. /**
  59227. * @constructor
  59228. * @param name - The rendering pipeline name (default: "")
  59229. * @param hdr - If high dynamic range textures should be used (default: true)
  59230. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59231. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59232. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59233. */
  59234. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59235. /**
  59236. * Get the class name
  59237. * @returns "DefaultRenderingPipeline"
  59238. */
  59239. getClassName(): string;
  59240. /**
  59241. * Force the compilation of the entire pipeline.
  59242. */
  59243. prepare(): void;
  59244. private _hasCleared;
  59245. private _prevPostProcess;
  59246. private _prevPrevPostProcess;
  59247. private _setAutoClearAndTextureSharing;
  59248. private _depthOfFieldSceneObserver;
  59249. private _buildPipeline;
  59250. private _disposePostProcesses;
  59251. /**
  59252. * Adds a camera to the pipeline
  59253. * @param camera the camera to be added
  59254. */
  59255. addCamera(camera: Camera): void;
  59256. /**
  59257. * Removes a camera from the pipeline
  59258. * @param camera the camera to remove
  59259. */
  59260. removeCamera(camera: Camera): void;
  59261. /**
  59262. * Dispose of the pipeline and stop all post processes
  59263. */
  59264. dispose(): void;
  59265. /**
  59266. * Serialize the rendering pipeline (Used when exporting)
  59267. * @returns the serialized object
  59268. */
  59269. serialize(): any;
  59270. /**
  59271. * Parse the serialized pipeline
  59272. * @param source Source pipeline.
  59273. * @param scene The scene to load the pipeline to.
  59274. * @param rootUrl The URL of the serialized pipeline.
  59275. * @returns An instantiated pipeline from the serialized object.
  59276. */
  59277. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59278. }
  59279. }
  59280. declare module BABYLON {
  59281. /** @hidden */
  59282. export var lensHighlightsPixelShader: {
  59283. name: string;
  59284. shader: string;
  59285. };
  59286. }
  59287. declare module BABYLON {
  59288. /** @hidden */
  59289. export var depthOfFieldPixelShader: {
  59290. name: string;
  59291. shader: string;
  59292. };
  59293. }
  59294. declare module BABYLON {
  59295. /**
  59296. * BABYLON.JS Chromatic Aberration GLSL Shader
  59297. * Author: Olivier Guyot
  59298. * Separates very slightly R, G and B colors on the edges of the screen
  59299. * Inspired by Francois Tarlier & Martins Upitis
  59300. */
  59301. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59302. /**
  59303. * @ignore
  59304. * The chromatic aberration PostProcess id in the pipeline
  59305. */
  59306. LensChromaticAberrationEffect: string;
  59307. /**
  59308. * @ignore
  59309. * The highlights enhancing PostProcess id in the pipeline
  59310. */
  59311. HighlightsEnhancingEffect: string;
  59312. /**
  59313. * @ignore
  59314. * The depth-of-field PostProcess id in the pipeline
  59315. */
  59316. LensDepthOfFieldEffect: string;
  59317. private _scene;
  59318. private _depthTexture;
  59319. private _grainTexture;
  59320. private _chromaticAberrationPostProcess;
  59321. private _highlightsPostProcess;
  59322. private _depthOfFieldPostProcess;
  59323. private _edgeBlur;
  59324. private _grainAmount;
  59325. private _chromaticAberration;
  59326. private _distortion;
  59327. private _highlightsGain;
  59328. private _highlightsThreshold;
  59329. private _dofDistance;
  59330. private _dofAperture;
  59331. private _dofDarken;
  59332. private _dofPentagon;
  59333. private _blurNoise;
  59334. /**
  59335. * @constructor
  59336. *
  59337. * Effect parameters are as follow:
  59338. * {
  59339. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59340. * edge_blur: number; // from 0 to x (1 for realism)
  59341. * distortion: number; // from 0 to x (1 for realism)
  59342. * grain_amount: number; // from 0 to 1
  59343. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59344. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59345. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59346. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59347. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59348. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59349. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59350. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59351. * }
  59352. * Note: if an effect parameter is unset, effect is disabled
  59353. *
  59354. * @param name The rendering pipeline name
  59355. * @param parameters - An object containing all parameters (see above)
  59356. * @param scene The scene linked to this pipeline
  59357. * @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)
  59358. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59359. */
  59360. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59361. /**
  59362. * Get the class name
  59363. * @returns "LensRenderingPipeline"
  59364. */
  59365. getClassName(): string;
  59366. /**
  59367. * Gets associated scene
  59368. */
  59369. readonly scene: Scene;
  59370. /**
  59371. * Gets or sets the edge blur
  59372. */
  59373. edgeBlur: number;
  59374. /**
  59375. * Gets or sets the grain amount
  59376. */
  59377. grainAmount: number;
  59378. /**
  59379. * Gets or sets the chromatic aberration amount
  59380. */
  59381. chromaticAberration: number;
  59382. /**
  59383. * Gets or sets the depth of field aperture
  59384. */
  59385. dofAperture: number;
  59386. /**
  59387. * Gets or sets the edge distortion
  59388. */
  59389. edgeDistortion: number;
  59390. /**
  59391. * Gets or sets the depth of field distortion
  59392. */
  59393. dofDistortion: number;
  59394. /**
  59395. * Gets or sets the darken out of focus amount
  59396. */
  59397. darkenOutOfFocus: number;
  59398. /**
  59399. * Gets or sets a boolean indicating if blur noise is enabled
  59400. */
  59401. blurNoise: boolean;
  59402. /**
  59403. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59404. */
  59405. pentagonBokeh: boolean;
  59406. /**
  59407. * Gets or sets the highlight grain amount
  59408. */
  59409. highlightsGain: number;
  59410. /**
  59411. * Gets or sets the highlight threshold
  59412. */
  59413. highlightsThreshold: number;
  59414. /**
  59415. * Sets the amount of blur at the edges
  59416. * @param amount blur amount
  59417. */
  59418. setEdgeBlur(amount: number): void;
  59419. /**
  59420. * Sets edge blur to 0
  59421. */
  59422. disableEdgeBlur(): void;
  59423. /**
  59424. * Sets the amout of grain
  59425. * @param amount Amount of grain
  59426. */
  59427. setGrainAmount(amount: number): void;
  59428. /**
  59429. * Set grain amount to 0
  59430. */
  59431. disableGrain(): void;
  59432. /**
  59433. * Sets the chromatic aberration amount
  59434. * @param amount amount of chromatic aberration
  59435. */
  59436. setChromaticAberration(amount: number): void;
  59437. /**
  59438. * Sets chromatic aberration amount to 0
  59439. */
  59440. disableChromaticAberration(): void;
  59441. /**
  59442. * Sets the EdgeDistortion amount
  59443. * @param amount amount of EdgeDistortion
  59444. */
  59445. setEdgeDistortion(amount: number): void;
  59446. /**
  59447. * Sets edge distortion to 0
  59448. */
  59449. disableEdgeDistortion(): void;
  59450. /**
  59451. * Sets the FocusDistance amount
  59452. * @param amount amount of FocusDistance
  59453. */
  59454. setFocusDistance(amount: number): void;
  59455. /**
  59456. * Disables depth of field
  59457. */
  59458. disableDepthOfField(): void;
  59459. /**
  59460. * Sets the Aperture amount
  59461. * @param amount amount of Aperture
  59462. */
  59463. setAperture(amount: number): void;
  59464. /**
  59465. * Sets the DarkenOutOfFocus amount
  59466. * @param amount amount of DarkenOutOfFocus
  59467. */
  59468. setDarkenOutOfFocus(amount: number): void;
  59469. private _pentagonBokehIsEnabled;
  59470. /**
  59471. * Creates a pentagon bokeh effect
  59472. */
  59473. enablePentagonBokeh(): void;
  59474. /**
  59475. * Disables the pentagon bokeh effect
  59476. */
  59477. disablePentagonBokeh(): void;
  59478. /**
  59479. * Enables noise blur
  59480. */
  59481. enableNoiseBlur(): void;
  59482. /**
  59483. * Disables noise blur
  59484. */
  59485. disableNoiseBlur(): void;
  59486. /**
  59487. * Sets the HighlightsGain amount
  59488. * @param amount amount of HighlightsGain
  59489. */
  59490. setHighlightsGain(amount: number): void;
  59491. /**
  59492. * Sets the HighlightsThreshold amount
  59493. * @param amount amount of HighlightsThreshold
  59494. */
  59495. setHighlightsThreshold(amount: number): void;
  59496. /**
  59497. * Disables highlights
  59498. */
  59499. disableHighlights(): void;
  59500. /**
  59501. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59502. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59503. */
  59504. dispose(disableDepthRender?: boolean): void;
  59505. private _createChromaticAberrationPostProcess;
  59506. private _createHighlightsPostProcess;
  59507. private _createDepthOfFieldPostProcess;
  59508. private _createGrainTexture;
  59509. }
  59510. }
  59511. declare module BABYLON {
  59512. /** @hidden */
  59513. export var ssao2PixelShader: {
  59514. name: string;
  59515. shader: string;
  59516. };
  59517. }
  59518. declare module BABYLON {
  59519. /** @hidden */
  59520. export var ssaoCombinePixelShader: {
  59521. name: string;
  59522. shader: string;
  59523. };
  59524. }
  59525. declare module BABYLON {
  59526. /**
  59527. * Render pipeline to produce ssao effect
  59528. */
  59529. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59530. /**
  59531. * @ignore
  59532. * The PassPostProcess id in the pipeline that contains the original scene color
  59533. */
  59534. SSAOOriginalSceneColorEffect: string;
  59535. /**
  59536. * @ignore
  59537. * The SSAO PostProcess id in the pipeline
  59538. */
  59539. SSAORenderEffect: string;
  59540. /**
  59541. * @ignore
  59542. * The horizontal blur PostProcess id in the pipeline
  59543. */
  59544. SSAOBlurHRenderEffect: string;
  59545. /**
  59546. * @ignore
  59547. * The vertical blur PostProcess id in the pipeline
  59548. */
  59549. SSAOBlurVRenderEffect: string;
  59550. /**
  59551. * @ignore
  59552. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59553. */
  59554. SSAOCombineRenderEffect: string;
  59555. /**
  59556. * The output strength of the SSAO post-process. Default value is 1.0.
  59557. */
  59558. totalStrength: number;
  59559. /**
  59560. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59561. */
  59562. maxZ: number;
  59563. /**
  59564. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59565. */
  59566. minZAspect: number;
  59567. private _samples;
  59568. /**
  59569. * Number of samples used for the SSAO calculations. Default value is 8
  59570. */
  59571. samples: number;
  59572. private _textureSamples;
  59573. /**
  59574. * Number of samples to use for antialiasing
  59575. */
  59576. textureSamples: number;
  59577. /**
  59578. * Ratio object used for SSAO ratio and blur ratio
  59579. */
  59580. private _ratio;
  59581. /**
  59582. * Dynamically generated sphere sampler.
  59583. */
  59584. private _sampleSphere;
  59585. /**
  59586. * Blur filter offsets
  59587. */
  59588. private _samplerOffsets;
  59589. private _expensiveBlur;
  59590. /**
  59591. * If bilateral blur should be used
  59592. */
  59593. expensiveBlur: boolean;
  59594. /**
  59595. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59596. */
  59597. radius: number;
  59598. /**
  59599. * The base color of the SSAO post-process
  59600. * The final result is "base + ssao" between [0, 1]
  59601. */
  59602. base: number;
  59603. /**
  59604. * Support test.
  59605. */
  59606. static readonly IsSupported: boolean;
  59607. private _scene;
  59608. private _depthTexture;
  59609. private _normalTexture;
  59610. private _randomTexture;
  59611. private _originalColorPostProcess;
  59612. private _ssaoPostProcess;
  59613. private _blurHPostProcess;
  59614. private _blurVPostProcess;
  59615. private _ssaoCombinePostProcess;
  59616. private _firstUpdate;
  59617. /**
  59618. * Gets active scene
  59619. */
  59620. readonly scene: Scene;
  59621. /**
  59622. * @constructor
  59623. * @param name The rendering pipeline name
  59624. * @param scene The scene linked to this pipeline
  59625. * @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 }
  59626. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59627. */
  59628. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59629. /**
  59630. * Get the class name
  59631. * @returns "SSAO2RenderingPipeline"
  59632. */
  59633. getClassName(): string;
  59634. /**
  59635. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59636. */
  59637. dispose(disableGeometryBufferRenderer?: boolean): void;
  59638. private _createBlurPostProcess;
  59639. /** @hidden */
  59640. _rebuild(): void;
  59641. private _bits;
  59642. private _radicalInverse_VdC;
  59643. private _hammersley;
  59644. private _hemisphereSample_uniform;
  59645. private _generateHemisphere;
  59646. private _createSSAOPostProcess;
  59647. private _createSSAOCombinePostProcess;
  59648. private _createRandomTexture;
  59649. /**
  59650. * Serialize the rendering pipeline (Used when exporting)
  59651. * @returns the serialized object
  59652. */
  59653. serialize(): any;
  59654. /**
  59655. * Parse the serialized pipeline
  59656. * @param source Source pipeline.
  59657. * @param scene The scene to load the pipeline to.
  59658. * @param rootUrl The URL of the serialized pipeline.
  59659. * @returns An instantiated pipeline from the serialized object.
  59660. */
  59661. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59662. }
  59663. }
  59664. declare module BABYLON {
  59665. /** @hidden */
  59666. export var ssaoPixelShader: {
  59667. name: string;
  59668. shader: string;
  59669. };
  59670. }
  59671. declare module BABYLON {
  59672. /**
  59673. * Render pipeline to produce ssao effect
  59674. */
  59675. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59676. /**
  59677. * @ignore
  59678. * The PassPostProcess id in the pipeline that contains the original scene color
  59679. */
  59680. SSAOOriginalSceneColorEffect: string;
  59681. /**
  59682. * @ignore
  59683. * The SSAO PostProcess id in the pipeline
  59684. */
  59685. SSAORenderEffect: string;
  59686. /**
  59687. * @ignore
  59688. * The horizontal blur PostProcess id in the pipeline
  59689. */
  59690. SSAOBlurHRenderEffect: string;
  59691. /**
  59692. * @ignore
  59693. * The vertical blur PostProcess id in the pipeline
  59694. */
  59695. SSAOBlurVRenderEffect: string;
  59696. /**
  59697. * @ignore
  59698. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59699. */
  59700. SSAOCombineRenderEffect: string;
  59701. /**
  59702. * The output strength of the SSAO post-process. Default value is 1.0.
  59703. */
  59704. totalStrength: number;
  59705. /**
  59706. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59707. */
  59708. radius: number;
  59709. /**
  59710. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59711. * Must not be equal to fallOff and superior to fallOff.
  59712. * Default value is 0.0075
  59713. */
  59714. area: number;
  59715. /**
  59716. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59717. * Must not be equal to area and inferior to area.
  59718. * Default value is 0.000001
  59719. */
  59720. fallOff: number;
  59721. /**
  59722. * The base color of the SSAO post-process
  59723. * The final result is "base + ssao" between [0, 1]
  59724. */
  59725. base: number;
  59726. private _scene;
  59727. private _depthTexture;
  59728. private _randomTexture;
  59729. private _originalColorPostProcess;
  59730. private _ssaoPostProcess;
  59731. private _blurHPostProcess;
  59732. private _blurVPostProcess;
  59733. private _ssaoCombinePostProcess;
  59734. private _firstUpdate;
  59735. /**
  59736. * Gets active scene
  59737. */
  59738. readonly scene: Scene;
  59739. /**
  59740. * @constructor
  59741. * @param name - The rendering pipeline name
  59742. * @param scene - The scene linked to this pipeline
  59743. * @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 }
  59744. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59745. */
  59746. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59747. /**
  59748. * Get the class name
  59749. * @returns "SSAORenderingPipeline"
  59750. */
  59751. getClassName(): string;
  59752. /**
  59753. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59754. */
  59755. dispose(disableDepthRender?: boolean): void;
  59756. private _createBlurPostProcess;
  59757. /** @hidden */
  59758. _rebuild(): void;
  59759. private _createSSAOPostProcess;
  59760. private _createSSAOCombinePostProcess;
  59761. private _createRandomTexture;
  59762. }
  59763. }
  59764. declare module BABYLON {
  59765. /** @hidden */
  59766. export var standardPixelShader: {
  59767. name: string;
  59768. shader: string;
  59769. };
  59770. }
  59771. declare module BABYLON {
  59772. /**
  59773. * Standard rendering pipeline
  59774. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59775. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59776. */
  59777. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59778. /**
  59779. * Public members
  59780. */
  59781. /**
  59782. * Post-process which contains the original scene color before the pipeline applies all the effects
  59783. */
  59784. originalPostProcess: Nullable<PostProcess>;
  59785. /**
  59786. * Post-process used to down scale an image x4
  59787. */
  59788. downSampleX4PostProcess: Nullable<PostProcess>;
  59789. /**
  59790. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59791. */
  59792. brightPassPostProcess: Nullable<PostProcess>;
  59793. /**
  59794. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59795. */
  59796. blurHPostProcesses: PostProcess[];
  59797. /**
  59798. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59799. */
  59800. blurVPostProcesses: PostProcess[];
  59801. /**
  59802. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59803. */
  59804. textureAdderPostProcess: Nullable<PostProcess>;
  59805. /**
  59806. * Post-process used to create volumetric lighting effect
  59807. */
  59808. volumetricLightPostProcess: Nullable<PostProcess>;
  59809. /**
  59810. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59811. */
  59812. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59813. /**
  59814. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59815. */
  59816. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59817. /**
  59818. * Post-process used to merge the volumetric light effect and the real scene color
  59819. */
  59820. volumetricLightMergePostProces: Nullable<PostProcess>;
  59821. /**
  59822. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59823. */
  59824. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59825. /**
  59826. * Base post-process used to calculate the average luminance of the final image for HDR
  59827. */
  59828. luminancePostProcess: Nullable<PostProcess>;
  59829. /**
  59830. * Post-processes used to create down sample post-processes in order to get
  59831. * the average luminance of the final image for HDR
  59832. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59833. */
  59834. luminanceDownSamplePostProcesses: PostProcess[];
  59835. /**
  59836. * Post-process used to create a HDR effect (light adaptation)
  59837. */
  59838. hdrPostProcess: Nullable<PostProcess>;
  59839. /**
  59840. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59841. */
  59842. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59843. /**
  59844. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59845. */
  59846. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59847. /**
  59848. * Post-process used to merge the final HDR post-process and the real scene color
  59849. */
  59850. hdrFinalPostProcess: Nullable<PostProcess>;
  59851. /**
  59852. * Post-process used to create a lens flare effect
  59853. */
  59854. lensFlarePostProcess: Nullable<PostProcess>;
  59855. /**
  59856. * Post-process that merges the result of the lens flare post-process and the real scene color
  59857. */
  59858. lensFlareComposePostProcess: Nullable<PostProcess>;
  59859. /**
  59860. * Post-process used to create a motion blur effect
  59861. */
  59862. motionBlurPostProcess: Nullable<PostProcess>;
  59863. /**
  59864. * Post-process used to create a depth of field effect
  59865. */
  59866. depthOfFieldPostProcess: Nullable<PostProcess>;
  59867. /**
  59868. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59869. */
  59870. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59871. /**
  59872. * Represents the brightness threshold in order to configure the illuminated surfaces
  59873. */
  59874. brightThreshold: number;
  59875. /**
  59876. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59877. */
  59878. blurWidth: number;
  59879. /**
  59880. * Sets if the blur for highlighted surfaces must be only horizontal
  59881. */
  59882. horizontalBlur: boolean;
  59883. /**
  59884. * Gets the overall exposure used by the pipeline
  59885. */
  59886. /**
  59887. * Sets the overall exposure used by the pipeline
  59888. */
  59889. exposure: number;
  59890. /**
  59891. * Texture used typically to simulate "dirty" on camera lens
  59892. */
  59893. lensTexture: Nullable<Texture>;
  59894. /**
  59895. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59896. */
  59897. volumetricLightCoefficient: number;
  59898. /**
  59899. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59900. */
  59901. volumetricLightPower: number;
  59902. /**
  59903. * Used the set the blur intensity to smooth the volumetric lights
  59904. */
  59905. volumetricLightBlurScale: number;
  59906. /**
  59907. * Light (spot or directional) used to generate the volumetric lights rays
  59908. * The source light must have a shadow generate so the pipeline can get its
  59909. * depth map
  59910. */
  59911. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59912. /**
  59913. * For eye adaptation, represents the minimum luminance the eye can see
  59914. */
  59915. hdrMinimumLuminance: number;
  59916. /**
  59917. * For eye adaptation, represents the decrease luminance speed
  59918. */
  59919. hdrDecreaseRate: number;
  59920. /**
  59921. * For eye adaptation, represents the increase luminance speed
  59922. */
  59923. hdrIncreaseRate: number;
  59924. /**
  59925. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59926. */
  59927. /**
  59928. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59929. */
  59930. hdrAutoExposure: boolean;
  59931. /**
  59932. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59933. */
  59934. lensColorTexture: Nullable<Texture>;
  59935. /**
  59936. * The overall strengh for the lens flare effect
  59937. */
  59938. lensFlareStrength: number;
  59939. /**
  59940. * Dispersion coefficient for lens flare ghosts
  59941. */
  59942. lensFlareGhostDispersal: number;
  59943. /**
  59944. * Main lens flare halo width
  59945. */
  59946. lensFlareHaloWidth: number;
  59947. /**
  59948. * Based on the lens distortion effect, defines how much the lens flare result
  59949. * is distorted
  59950. */
  59951. lensFlareDistortionStrength: number;
  59952. /**
  59953. * Configures the blur intensity used for for lens flare (halo)
  59954. */
  59955. lensFlareBlurWidth: number;
  59956. /**
  59957. * Lens star texture must be used to simulate rays on the flares and is available
  59958. * in the documentation
  59959. */
  59960. lensStarTexture: Nullable<Texture>;
  59961. /**
  59962. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59963. * flare effect by taking account of the dirt texture
  59964. */
  59965. lensFlareDirtTexture: Nullable<Texture>;
  59966. /**
  59967. * Represents the focal length for the depth of field effect
  59968. */
  59969. depthOfFieldDistance: number;
  59970. /**
  59971. * Represents the blur intensity for the blurred part of the depth of field effect
  59972. */
  59973. depthOfFieldBlurWidth: number;
  59974. /**
  59975. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59976. */
  59977. /**
  59978. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59979. */
  59980. motionStrength: number;
  59981. /**
  59982. * Gets wether or not the motion blur post-process is object based or screen based.
  59983. */
  59984. /**
  59985. * Sets wether or not the motion blur post-process should be object based or screen based
  59986. */
  59987. objectBasedMotionBlur: boolean;
  59988. /**
  59989. * List of animations for the pipeline (IAnimatable implementation)
  59990. */
  59991. animations: Animation[];
  59992. /**
  59993. * Private members
  59994. */
  59995. private _scene;
  59996. private _currentDepthOfFieldSource;
  59997. private _basePostProcess;
  59998. private _fixedExposure;
  59999. private _currentExposure;
  60000. private _hdrAutoExposure;
  60001. private _hdrCurrentLuminance;
  60002. private _motionStrength;
  60003. private _isObjectBasedMotionBlur;
  60004. private _floatTextureType;
  60005. private _camerasToBeAttached;
  60006. private _ratio;
  60007. private _bloomEnabled;
  60008. private _depthOfFieldEnabled;
  60009. private _vlsEnabled;
  60010. private _lensFlareEnabled;
  60011. private _hdrEnabled;
  60012. private _motionBlurEnabled;
  60013. private _fxaaEnabled;
  60014. private _motionBlurSamples;
  60015. private _volumetricLightStepsCount;
  60016. private _samples;
  60017. /**
  60018. * @ignore
  60019. * Specifies if the bloom pipeline is enabled
  60020. */
  60021. BloomEnabled: boolean;
  60022. /**
  60023. * @ignore
  60024. * Specifies if the depth of field pipeline is enabed
  60025. */
  60026. DepthOfFieldEnabled: boolean;
  60027. /**
  60028. * @ignore
  60029. * Specifies if the lens flare pipeline is enabed
  60030. */
  60031. LensFlareEnabled: boolean;
  60032. /**
  60033. * @ignore
  60034. * Specifies if the HDR pipeline is enabled
  60035. */
  60036. HDREnabled: boolean;
  60037. /**
  60038. * @ignore
  60039. * Specifies if the volumetric lights scattering effect is enabled
  60040. */
  60041. VLSEnabled: boolean;
  60042. /**
  60043. * @ignore
  60044. * Specifies if the motion blur effect is enabled
  60045. */
  60046. MotionBlurEnabled: boolean;
  60047. /**
  60048. * Specifies if anti-aliasing is enabled
  60049. */
  60050. fxaaEnabled: boolean;
  60051. /**
  60052. * Specifies the number of steps used to calculate the volumetric lights
  60053. * Typically in interval [50, 200]
  60054. */
  60055. volumetricLightStepsCount: number;
  60056. /**
  60057. * Specifies the number of samples used for the motion blur effect
  60058. * Typically in interval [16, 64]
  60059. */
  60060. motionBlurSamples: number;
  60061. /**
  60062. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60063. */
  60064. samples: number;
  60065. /**
  60066. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60067. * @constructor
  60068. * @param name The rendering pipeline name
  60069. * @param scene The scene linked to this pipeline
  60070. * @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)
  60071. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60072. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60073. */
  60074. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60075. private _buildPipeline;
  60076. private _createDownSampleX4PostProcess;
  60077. private _createBrightPassPostProcess;
  60078. private _createBlurPostProcesses;
  60079. private _createTextureAdderPostProcess;
  60080. private _createVolumetricLightPostProcess;
  60081. private _createLuminancePostProcesses;
  60082. private _createHdrPostProcess;
  60083. private _createLensFlarePostProcess;
  60084. private _createDepthOfFieldPostProcess;
  60085. private _createMotionBlurPostProcess;
  60086. private _getDepthTexture;
  60087. private _disposePostProcesses;
  60088. /**
  60089. * Dispose of the pipeline and stop all post processes
  60090. */
  60091. dispose(): void;
  60092. /**
  60093. * Serialize the rendering pipeline (Used when exporting)
  60094. * @returns the serialized object
  60095. */
  60096. serialize(): any;
  60097. /**
  60098. * Parse the serialized pipeline
  60099. * @param source Source pipeline.
  60100. * @param scene The scene to load the pipeline to.
  60101. * @param rootUrl The URL of the serialized pipeline.
  60102. * @returns An instantiated pipeline from the serialized object.
  60103. */
  60104. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60105. /**
  60106. * Luminance steps
  60107. */
  60108. static LuminanceSteps: number;
  60109. }
  60110. }
  60111. declare module BABYLON {
  60112. /** @hidden */
  60113. export var tonemapPixelShader: {
  60114. name: string;
  60115. shader: string;
  60116. };
  60117. }
  60118. declare module BABYLON {
  60119. /** Defines operator used for tonemapping */
  60120. export enum TonemappingOperator {
  60121. /** Hable */
  60122. Hable = 0,
  60123. /** Reinhard */
  60124. Reinhard = 1,
  60125. /** HejiDawson */
  60126. HejiDawson = 2,
  60127. /** Photographic */
  60128. Photographic = 3
  60129. }
  60130. /**
  60131. * Defines a post process to apply tone mapping
  60132. */
  60133. export class TonemapPostProcess extends PostProcess {
  60134. private _operator;
  60135. /** Defines the required exposure adjustement */
  60136. exposureAdjustment: number;
  60137. /**
  60138. * Creates a new TonemapPostProcess
  60139. * @param name defines the name of the postprocess
  60140. * @param _operator defines the operator to use
  60141. * @param exposureAdjustment defines the required exposure adjustement
  60142. * @param camera defines the camera to use (can be null)
  60143. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60144. * @param engine defines the hosting engine (can be ignore if camera is set)
  60145. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60146. */
  60147. constructor(name: string, _operator: TonemappingOperator,
  60148. /** Defines the required exposure adjustement */
  60149. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60150. }
  60151. }
  60152. declare module BABYLON {
  60153. /** @hidden */
  60154. export var depthVertexShader: {
  60155. name: string;
  60156. shader: string;
  60157. };
  60158. }
  60159. declare module BABYLON {
  60160. /** @hidden */
  60161. export var volumetricLightScatteringPixelShader: {
  60162. name: string;
  60163. shader: string;
  60164. };
  60165. }
  60166. declare module BABYLON {
  60167. /** @hidden */
  60168. export var volumetricLightScatteringPassVertexShader: {
  60169. name: string;
  60170. shader: string;
  60171. };
  60172. }
  60173. declare module BABYLON {
  60174. /** @hidden */
  60175. export var volumetricLightScatteringPassPixelShader: {
  60176. name: string;
  60177. shader: string;
  60178. };
  60179. }
  60180. declare module BABYLON {
  60181. /**
  60182. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60183. */
  60184. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60185. private _volumetricLightScatteringPass;
  60186. private _volumetricLightScatteringRTT;
  60187. private _viewPort;
  60188. private _screenCoordinates;
  60189. private _cachedDefines;
  60190. /**
  60191. * If not undefined, the mesh position is computed from the attached node position
  60192. */
  60193. attachedNode: {
  60194. position: Vector3;
  60195. };
  60196. /**
  60197. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60198. */
  60199. customMeshPosition: Vector3;
  60200. /**
  60201. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60202. */
  60203. useCustomMeshPosition: boolean;
  60204. /**
  60205. * If the post-process should inverse the light scattering direction
  60206. */
  60207. invert: boolean;
  60208. /**
  60209. * The internal mesh used by the post-process
  60210. */
  60211. mesh: Mesh;
  60212. /**
  60213. * @hidden
  60214. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60215. */
  60216. useDiffuseColor: boolean;
  60217. /**
  60218. * Array containing the excluded meshes not rendered in the internal pass
  60219. */
  60220. excludedMeshes: AbstractMesh[];
  60221. /**
  60222. * Controls the overall intensity of the post-process
  60223. */
  60224. exposure: number;
  60225. /**
  60226. * Dissipates each sample's contribution in range [0, 1]
  60227. */
  60228. decay: number;
  60229. /**
  60230. * Controls the overall intensity of each sample
  60231. */
  60232. weight: number;
  60233. /**
  60234. * Controls the density of each sample
  60235. */
  60236. density: number;
  60237. /**
  60238. * @constructor
  60239. * @param name The post-process name
  60240. * @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)
  60241. * @param camera The camera that the post-process will be attached to
  60242. * @param mesh The mesh used to create the light scattering
  60243. * @param samples The post-process quality, default 100
  60244. * @param samplingModeThe post-process filtering mode
  60245. * @param engine The babylon engine
  60246. * @param reusable If the post-process is reusable
  60247. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60248. */
  60249. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60250. /**
  60251. * Returns the string "VolumetricLightScatteringPostProcess"
  60252. * @returns "VolumetricLightScatteringPostProcess"
  60253. */
  60254. getClassName(): string;
  60255. private _isReady;
  60256. /**
  60257. * Sets the new light position for light scattering effect
  60258. * @param position The new custom light position
  60259. */
  60260. setCustomMeshPosition(position: Vector3): void;
  60261. /**
  60262. * Returns the light position for light scattering effect
  60263. * @return Vector3 The custom light position
  60264. */
  60265. getCustomMeshPosition(): Vector3;
  60266. /**
  60267. * Disposes the internal assets and detaches the post-process from the camera
  60268. */
  60269. dispose(camera: Camera): void;
  60270. /**
  60271. * Returns the render target texture used by the post-process
  60272. * @return the render target texture used by the post-process
  60273. */
  60274. getPass(): RenderTargetTexture;
  60275. private _meshExcluded;
  60276. private _createPass;
  60277. private _updateMeshScreenCoordinates;
  60278. /**
  60279. * Creates a default mesh for the Volumeric Light Scattering post-process
  60280. * @param name The mesh name
  60281. * @param scene The scene where to create the mesh
  60282. * @return the default mesh
  60283. */
  60284. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60285. }
  60286. }
  60287. declare module BABYLON {
  60288. interface Scene {
  60289. /** @hidden (Backing field) */
  60290. _boundingBoxRenderer: BoundingBoxRenderer;
  60291. /** @hidden (Backing field) */
  60292. _forceShowBoundingBoxes: boolean;
  60293. /**
  60294. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60295. */
  60296. forceShowBoundingBoxes: boolean;
  60297. /**
  60298. * Gets the bounding box renderer associated with the scene
  60299. * @returns a BoundingBoxRenderer
  60300. */
  60301. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60302. }
  60303. interface AbstractMesh {
  60304. /** @hidden (Backing field) */
  60305. _showBoundingBox: boolean;
  60306. /**
  60307. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60308. */
  60309. showBoundingBox: boolean;
  60310. }
  60311. /**
  60312. * Component responsible of rendering the bounding box of the meshes in a scene.
  60313. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60314. */
  60315. export class BoundingBoxRenderer implements ISceneComponent {
  60316. /**
  60317. * The component name helpfull to identify the component in the list of scene components.
  60318. */
  60319. readonly name: string;
  60320. /**
  60321. * The scene the component belongs to.
  60322. */
  60323. scene: Scene;
  60324. /**
  60325. * Color of the bounding box lines placed in front of an object
  60326. */
  60327. frontColor: Color3;
  60328. /**
  60329. * Color of the bounding box lines placed behind an object
  60330. */
  60331. backColor: Color3;
  60332. /**
  60333. * Defines if the renderer should show the back lines or not
  60334. */
  60335. showBackLines: boolean;
  60336. /**
  60337. * @hidden
  60338. */
  60339. renderList: SmartArray<BoundingBox>;
  60340. private _colorShader;
  60341. private _vertexBuffers;
  60342. private _indexBuffer;
  60343. private _fillIndexBuffer;
  60344. private _fillIndexData;
  60345. /**
  60346. * Instantiates a new bounding box renderer in a scene.
  60347. * @param scene the scene the renderer renders in
  60348. */
  60349. constructor(scene: Scene);
  60350. /**
  60351. * Registers the component in a given scene
  60352. */
  60353. register(): void;
  60354. private _evaluateSubMesh;
  60355. private _activeMesh;
  60356. private _prepareRessources;
  60357. private _createIndexBuffer;
  60358. /**
  60359. * Rebuilds the elements related to this component in case of
  60360. * context lost for instance.
  60361. */
  60362. rebuild(): void;
  60363. /**
  60364. * @hidden
  60365. */
  60366. reset(): void;
  60367. /**
  60368. * Render the bounding boxes of a specific rendering group
  60369. * @param renderingGroupId defines the rendering group to render
  60370. */
  60371. render(renderingGroupId: number): void;
  60372. /**
  60373. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60374. * @param mesh Define the mesh to render the occlusion bounding box for
  60375. */
  60376. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60377. /**
  60378. * Dispose and release the resources attached to this renderer.
  60379. */
  60380. dispose(): void;
  60381. }
  60382. }
  60383. declare module BABYLON {
  60384. /** @hidden */
  60385. export var depthPixelShader: {
  60386. name: string;
  60387. shader: string;
  60388. };
  60389. }
  60390. declare module BABYLON {
  60391. /**
  60392. * This represents a depth renderer in Babylon.
  60393. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60394. */
  60395. export class DepthRenderer {
  60396. private _scene;
  60397. private _depthMap;
  60398. private _effect;
  60399. private readonly _storeNonLinearDepth;
  60400. private readonly _clearColor;
  60401. /** Get if the depth renderer is using packed depth or not */
  60402. readonly isPacked: boolean;
  60403. private _cachedDefines;
  60404. private _camera;
  60405. /**
  60406. * Specifiess that the depth renderer will only be used within
  60407. * the camera it is created for.
  60408. * This can help forcing its rendering during the camera processing.
  60409. */
  60410. useOnlyInActiveCamera: boolean;
  60411. /** @hidden */
  60412. static _SceneComponentInitialization: (scene: Scene) => void;
  60413. /**
  60414. * Instantiates a depth renderer
  60415. * @param scene The scene the renderer belongs to
  60416. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60417. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60418. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60419. */
  60420. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60421. /**
  60422. * Creates the depth rendering effect and checks if the effect is ready.
  60423. * @param subMesh The submesh to be used to render the depth map of
  60424. * @param useInstances If multiple world instances should be used
  60425. * @returns if the depth renderer is ready to render the depth map
  60426. */
  60427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60428. /**
  60429. * Gets the texture which the depth map will be written to.
  60430. * @returns The depth map texture
  60431. */
  60432. getDepthMap(): RenderTargetTexture;
  60433. /**
  60434. * Disposes of the depth renderer.
  60435. */
  60436. dispose(): void;
  60437. }
  60438. }
  60439. declare module BABYLON {
  60440. interface Scene {
  60441. /** @hidden (Backing field) */
  60442. _depthRenderer: {
  60443. [id: string]: DepthRenderer;
  60444. };
  60445. /**
  60446. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60447. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60448. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60449. * @returns the created depth renderer
  60450. */
  60451. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60452. /**
  60453. * Disables a depth renderer for a given camera
  60454. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60455. */
  60456. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60457. }
  60458. /**
  60459. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60460. * in several rendering techniques.
  60461. */
  60462. export class DepthRendererSceneComponent implements ISceneComponent {
  60463. /**
  60464. * The component name helpfull to identify the component in the list of scene components.
  60465. */
  60466. readonly name: string;
  60467. /**
  60468. * The scene the component belongs to.
  60469. */
  60470. scene: Scene;
  60471. /**
  60472. * Creates a new instance of the component for the given scene
  60473. * @param scene Defines the scene to register the component in
  60474. */
  60475. constructor(scene: Scene);
  60476. /**
  60477. * Registers the component in a given scene
  60478. */
  60479. register(): void;
  60480. /**
  60481. * Rebuilds the elements related to this component in case of
  60482. * context lost for instance.
  60483. */
  60484. rebuild(): void;
  60485. /**
  60486. * Disposes the component and the associated ressources
  60487. */
  60488. dispose(): void;
  60489. private _gatherRenderTargets;
  60490. private _gatherActiveCameraRenderTargets;
  60491. }
  60492. }
  60493. declare module BABYLON {
  60494. /** @hidden */
  60495. export var outlinePixelShader: {
  60496. name: string;
  60497. shader: string;
  60498. };
  60499. }
  60500. declare module BABYLON {
  60501. /** @hidden */
  60502. export var outlineVertexShader: {
  60503. name: string;
  60504. shader: string;
  60505. };
  60506. }
  60507. declare module BABYLON {
  60508. interface Scene {
  60509. /** @hidden */
  60510. _outlineRenderer: OutlineRenderer;
  60511. /**
  60512. * Gets the outline renderer associated with the scene
  60513. * @returns a OutlineRenderer
  60514. */
  60515. getOutlineRenderer(): OutlineRenderer;
  60516. }
  60517. interface AbstractMesh {
  60518. /** @hidden (Backing field) */
  60519. _renderOutline: boolean;
  60520. /**
  60521. * Gets or sets a boolean indicating if the outline must be rendered as well
  60522. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60523. */
  60524. renderOutline: boolean;
  60525. /** @hidden (Backing field) */
  60526. _renderOverlay: boolean;
  60527. /**
  60528. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60529. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60530. */
  60531. renderOverlay: boolean;
  60532. }
  60533. /**
  60534. * This class is responsible to draw bothe outline/overlay of meshes.
  60535. * It should not be used directly but through the available method on mesh.
  60536. */
  60537. export class OutlineRenderer implements ISceneComponent {
  60538. /**
  60539. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60540. */
  60541. private static _StencilReference;
  60542. /**
  60543. * The name of the component. Each component must have a unique name.
  60544. */
  60545. name: string;
  60546. /**
  60547. * The scene the component belongs to.
  60548. */
  60549. scene: Scene;
  60550. /**
  60551. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60552. */
  60553. zOffset: number;
  60554. private _engine;
  60555. private _effect;
  60556. private _cachedDefines;
  60557. private _savedDepthWrite;
  60558. /**
  60559. * Instantiates a new outline renderer. (There could be only one per scene).
  60560. * @param scene Defines the scene it belongs to
  60561. */
  60562. constructor(scene: Scene);
  60563. /**
  60564. * Register the component to one instance of a scene.
  60565. */
  60566. register(): void;
  60567. /**
  60568. * Rebuilds the elements related to this component in case of
  60569. * context lost for instance.
  60570. */
  60571. rebuild(): void;
  60572. /**
  60573. * Disposes the component and the associated ressources.
  60574. */
  60575. dispose(): void;
  60576. /**
  60577. * Renders the outline in the canvas.
  60578. * @param subMesh Defines the sumesh to render
  60579. * @param batch Defines the batch of meshes in case of instances
  60580. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60581. */
  60582. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60583. /**
  60584. * Returns whether or not the outline renderer is ready for a given submesh.
  60585. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60586. * @param subMesh Defines the submesh to check readyness for
  60587. * @param useInstances Defines wheter wee are trying to render instances or not
  60588. * @returns true if ready otherwise false
  60589. */
  60590. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60591. private _beforeRenderingMesh;
  60592. private _afterRenderingMesh;
  60593. }
  60594. }
  60595. declare module BABYLON {
  60596. /**
  60597. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60598. * @see http://doc.babylonjs.com/babylon101/sprites
  60599. */
  60600. export class SpritePackedManager extends SpriteManager {
  60601. /** defines the packed manager's name */
  60602. name: string;
  60603. /**
  60604. * Creates a new sprite manager from a packed sprite sheet
  60605. * @param name defines the manager's name
  60606. * @param imgUrl defines the sprite sheet url
  60607. * @param capacity defines the maximum allowed number of sprites
  60608. * @param scene defines the hosting scene
  60609. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60610. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60611. * @param samplingMode defines the smapling mode to use with spritesheet
  60612. * @param fromPacked set to true; do not alter
  60613. */
  60614. constructor(
  60615. /** defines the packed manager's name */
  60616. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60617. }
  60618. }
  60619. declare module BABYLON {
  60620. /**
  60621. * Defines the list of states available for a task inside a AssetsManager
  60622. */
  60623. export enum AssetTaskState {
  60624. /**
  60625. * Initialization
  60626. */
  60627. INIT = 0,
  60628. /**
  60629. * Running
  60630. */
  60631. RUNNING = 1,
  60632. /**
  60633. * Done
  60634. */
  60635. DONE = 2,
  60636. /**
  60637. * Error
  60638. */
  60639. ERROR = 3
  60640. }
  60641. /**
  60642. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60643. */
  60644. export abstract class AbstractAssetTask {
  60645. /**
  60646. * Task name
  60647. */ name: string;
  60648. /**
  60649. * Callback called when the task is successful
  60650. */
  60651. onSuccess: (task: any) => void;
  60652. /**
  60653. * Callback called when the task is not successful
  60654. */
  60655. onError: (task: any, message?: string, exception?: any) => void;
  60656. /**
  60657. * Creates a new AssetsManager
  60658. * @param name defines the name of the task
  60659. */
  60660. constructor(
  60661. /**
  60662. * Task name
  60663. */ name: string);
  60664. private _isCompleted;
  60665. private _taskState;
  60666. private _errorObject;
  60667. /**
  60668. * Get if the task is completed
  60669. */
  60670. readonly isCompleted: boolean;
  60671. /**
  60672. * Gets the current state of the task
  60673. */
  60674. readonly taskState: AssetTaskState;
  60675. /**
  60676. * Gets the current error object (if task is in error)
  60677. */
  60678. readonly errorObject: {
  60679. message?: string;
  60680. exception?: any;
  60681. };
  60682. /**
  60683. * Internal only
  60684. * @hidden
  60685. */
  60686. _setErrorObject(message?: string, exception?: any): void;
  60687. /**
  60688. * Execute the current task
  60689. * @param scene defines the scene where you want your assets to be loaded
  60690. * @param onSuccess is a callback called when the task is successfully executed
  60691. * @param onError is a callback called if an error occurs
  60692. */
  60693. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60694. /**
  60695. * Execute the current task
  60696. * @param scene defines the scene where you want your assets to be loaded
  60697. * @param onSuccess is a callback called when the task is successfully executed
  60698. * @param onError is a callback called if an error occurs
  60699. */
  60700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60701. /**
  60702. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60703. * This can be used with failed tasks that have the reason for failure fixed.
  60704. */
  60705. reset(): void;
  60706. private onErrorCallback;
  60707. private onDoneCallback;
  60708. }
  60709. /**
  60710. * Define the interface used by progress events raised during assets loading
  60711. */
  60712. export interface IAssetsProgressEvent {
  60713. /**
  60714. * Defines the number of remaining tasks to process
  60715. */
  60716. remainingCount: number;
  60717. /**
  60718. * Defines the total number of tasks
  60719. */
  60720. totalCount: number;
  60721. /**
  60722. * Defines the task that was just processed
  60723. */
  60724. task: AbstractAssetTask;
  60725. }
  60726. /**
  60727. * Class used to share progress information about assets loading
  60728. */
  60729. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60730. /**
  60731. * Defines the number of remaining tasks to process
  60732. */
  60733. remainingCount: number;
  60734. /**
  60735. * Defines the total number of tasks
  60736. */
  60737. totalCount: number;
  60738. /**
  60739. * Defines the task that was just processed
  60740. */
  60741. task: AbstractAssetTask;
  60742. /**
  60743. * Creates a AssetsProgressEvent
  60744. * @param remainingCount defines the number of remaining tasks to process
  60745. * @param totalCount defines the total number of tasks
  60746. * @param task defines the task that was just processed
  60747. */
  60748. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60749. }
  60750. /**
  60751. * Define a task used by AssetsManager to load meshes
  60752. */
  60753. export class MeshAssetTask extends AbstractAssetTask {
  60754. /**
  60755. * Defines the name of the task
  60756. */
  60757. name: string;
  60758. /**
  60759. * Defines the list of mesh's names you want to load
  60760. */
  60761. meshesNames: any;
  60762. /**
  60763. * Defines the root url to use as a base to load your meshes and associated resources
  60764. */
  60765. rootUrl: string;
  60766. /**
  60767. * Defines the filename of the scene to load from
  60768. */
  60769. sceneFilename: string;
  60770. /**
  60771. * Gets the list of loaded meshes
  60772. */
  60773. loadedMeshes: Array<AbstractMesh>;
  60774. /**
  60775. * Gets the list of loaded particle systems
  60776. */
  60777. loadedParticleSystems: Array<IParticleSystem>;
  60778. /**
  60779. * Gets the list of loaded skeletons
  60780. */
  60781. loadedSkeletons: Array<Skeleton>;
  60782. /**
  60783. * Gets the list of loaded animation groups
  60784. */
  60785. loadedAnimationGroups: Array<AnimationGroup>;
  60786. /**
  60787. * Callback called when the task is successful
  60788. */
  60789. onSuccess: (task: MeshAssetTask) => void;
  60790. /**
  60791. * Callback called when the task is successful
  60792. */
  60793. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60794. /**
  60795. * Creates a new MeshAssetTask
  60796. * @param name defines the name of the task
  60797. * @param meshesNames defines the list of mesh's names you want to load
  60798. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60799. * @param sceneFilename defines the filename of the scene to load from
  60800. */
  60801. constructor(
  60802. /**
  60803. * Defines the name of the task
  60804. */
  60805. name: string,
  60806. /**
  60807. * Defines the list of mesh's names you want to load
  60808. */
  60809. meshesNames: any,
  60810. /**
  60811. * Defines the root url to use as a base to load your meshes and associated resources
  60812. */
  60813. rootUrl: string,
  60814. /**
  60815. * Defines the filename of the scene to load from
  60816. */
  60817. sceneFilename: string);
  60818. /**
  60819. * Execute the current task
  60820. * @param scene defines the scene where you want your assets to be loaded
  60821. * @param onSuccess is a callback called when the task is successfully executed
  60822. * @param onError is a callback called if an error occurs
  60823. */
  60824. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60825. }
  60826. /**
  60827. * Define a task used by AssetsManager to load text content
  60828. */
  60829. export class TextFileAssetTask extends AbstractAssetTask {
  60830. /**
  60831. * Defines the name of the task
  60832. */
  60833. name: string;
  60834. /**
  60835. * Defines the location of the file to load
  60836. */
  60837. url: string;
  60838. /**
  60839. * Gets the loaded text string
  60840. */
  60841. text: string;
  60842. /**
  60843. * Callback called when the task is successful
  60844. */
  60845. onSuccess: (task: TextFileAssetTask) => void;
  60846. /**
  60847. * Callback called when the task is successful
  60848. */
  60849. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60850. /**
  60851. * Creates a new TextFileAssetTask object
  60852. * @param name defines the name of the task
  60853. * @param url defines the location of the file to load
  60854. */
  60855. constructor(
  60856. /**
  60857. * Defines the name of the task
  60858. */
  60859. name: string,
  60860. /**
  60861. * Defines the location of the file to load
  60862. */
  60863. url: string);
  60864. /**
  60865. * Execute the current task
  60866. * @param scene defines the scene where you want your assets to be loaded
  60867. * @param onSuccess is a callback called when the task is successfully executed
  60868. * @param onError is a callback called if an error occurs
  60869. */
  60870. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60871. }
  60872. /**
  60873. * Define a task used by AssetsManager to load binary data
  60874. */
  60875. export class BinaryFileAssetTask extends AbstractAssetTask {
  60876. /**
  60877. * Defines the name of the task
  60878. */
  60879. name: string;
  60880. /**
  60881. * Defines the location of the file to load
  60882. */
  60883. url: string;
  60884. /**
  60885. * Gets the lodaded data (as an array buffer)
  60886. */
  60887. data: ArrayBuffer;
  60888. /**
  60889. * Callback called when the task is successful
  60890. */
  60891. onSuccess: (task: BinaryFileAssetTask) => void;
  60892. /**
  60893. * Callback called when the task is successful
  60894. */
  60895. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60896. /**
  60897. * Creates a new BinaryFileAssetTask object
  60898. * @param name defines the name of the new task
  60899. * @param url defines the location of the file to load
  60900. */
  60901. constructor(
  60902. /**
  60903. * Defines the name of the task
  60904. */
  60905. name: string,
  60906. /**
  60907. * Defines the location of the file to load
  60908. */
  60909. url: string);
  60910. /**
  60911. * Execute the current task
  60912. * @param scene defines the scene where you want your assets to be loaded
  60913. * @param onSuccess is a callback called when the task is successfully executed
  60914. * @param onError is a callback called if an error occurs
  60915. */
  60916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60917. }
  60918. /**
  60919. * Define a task used by AssetsManager to load images
  60920. */
  60921. export class ImageAssetTask extends AbstractAssetTask {
  60922. /**
  60923. * Defines the name of the task
  60924. */
  60925. name: string;
  60926. /**
  60927. * Defines the location of the image to load
  60928. */
  60929. url: string;
  60930. /**
  60931. * Gets the loaded images
  60932. */
  60933. image: HTMLImageElement;
  60934. /**
  60935. * Callback called when the task is successful
  60936. */
  60937. onSuccess: (task: ImageAssetTask) => void;
  60938. /**
  60939. * Callback called when the task is successful
  60940. */
  60941. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60942. /**
  60943. * Creates a new ImageAssetTask
  60944. * @param name defines the name of the task
  60945. * @param url defines the location of the image to load
  60946. */
  60947. constructor(
  60948. /**
  60949. * Defines the name of the task
  60950. */
  60951. name: string,
  60952. /**
  60953. * Defines the location of the image to load
  60954. */
  60955. url: string);
  60956. /**
  60957. * Execute the current task
  60958. * @param scene defines the scene where you want your assets to be loaded
  60959. * @param onSuccess is a callback called when the task is successfully executed
  60960. * @param onError is a callback called if an error occurs
  60961. */
  60962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60963. }
  60964. /**
  60965. * Defines the interface used by texture loading tasks
  60966. */
  60967. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60968. /**
  60969. * Gets the loaded texture
  60970. */
  60971. texture: TEX;
  60972. }
  60973. /**
  60974. * Define a task used by AssetsManager to load 2D textures
  60975. */
  60976. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60977. /**
  60978. * Defines the name of the task
  60979. */
  60980. name: string;
  60981. /**
  60982. * Defines the location of the file to load
  60983. */
  60984. url: string;
  60985. /**
  60986. * Defines if mipmap should not be generated (default is false)
  60987. */
  60988. noMipmap?: boolean | undefined;
  60989. /**
  60990. * Defines if texture must be inverted on Y axis (default is false)
  60991. */
  60992. invertY?: boolean | undefined;
  60993. /**
  60994. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60995. */
  60996. samplingMode: number;
  60997. /**
  60998. * Gets the loaded texture
  60999. */
  61000. texture: Texture;
  61001. /**
  61002. * Callback called when the task is successful
  61003. */
  61004. onSuccess: (task: TextureAssetTask) => void;
  61005. /**
  61006. * Callback called when the task is successful
  61007. */
  61008. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61009. /**
  61010. * Creates a new TextureAssetTask object
  61011. * @param name defines the name of the task
  61012. * @param url defines the location of the file to load
  61013. * @param noMipmap defines if mipmap should not be generated (default is false)
  61014. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61015. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61016. */
  61017. constructor(
  61018. /**
  61019. * Defines the name of the task
  61020. */
  61021. name: string,
  61022. /**
  61023. * Defines the location of the file to load
  61024. */
  61025. url: string,
  61026. /**
  61027. * Defines if mipmap should not be generated (default is false)
  61028. */
  61029. noMipmap?: boolean | undefined,
  61030. /**
  61031. * Defines if texture must be inverted on Y axis (default is false)
  61032. */
  61033. invertY?: boolean | undefined,
  61034. /**
  61035. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61036. */
  61037. samplingMode?: number);
  61038. /**
  61039. * Execute the current task
  61040. * @param scene defines the scene where you want your assets to be loaded
  61041. * @param onSuccess is a callback called when the task is successfully executed
  61042. * @param onError is a callback called if an error occurs
  61043. */
  61044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61045. }
  61046. /**
  61047. * Define a task used by AssetsManager to load cube textures
  61048. */
  61049. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61050. /**
  61051. * Defines the name of the task
  61052. */
  61053. name: string;
  61054. /**
  61055. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61056. */
  61057. url: string;
  61058. /**
  61059. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61060. */
  61061. extensions?: string[] | undefined;
  61062. /**
  61063. * Defines if mipmaps should not be generated (default is false)
  61064. */
  61065. noMipmap?: boolean | undefined;
  61066. /**
  61067. * Defines the explicit list of files (undefined by default)
  61068. */
  61069. files?: string[] | undefined;
  61070. /**
  61071. * Gets the loaded texture
  61072. */
  61073. texture: CubeTexture;
  61074. /**
  61075. * Callback called when the task is successful
  61076. */
  61077. onSuccess: (task: CubeTextureAssetTask) => void;
  61078. /**
  61079. * Callback called when the task is successful
  61080. */
  61081. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61082. /**
  61083. * Creates a new CubeTextureAssetTask
  61084. * @param name defines the name of the task
  61085. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61086. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61087. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61088. * @param files defines the explicit list of files (undefined by default)
  61089. */
  61090. constructor(
  61091. /**
  61092. * Defines the name of the task
  61093. */
  61094. name: string,
  61095. /**
  61096. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61097. */
  61098. url: string,
  61099. /**
  61100. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61101. */
  61102. extensions?: string[] | undefined,
  61103. /**
  61104. * Defines if mipmaps should not be generated (default is false)
  61105. */
  61106. noMipmap?: boolean | undefined,
  61107. /**
  61108. * Defines the explicit list of files (undefined by default)
  61109. */
  61110. files?: string[] | undefined);
  61111. /**
  61112. * Execute the current task
  61113. * @param scene defines the scene where you want your assets to be loaded
  61114. * @param onSuccess is a callback called when the task is successfully executed
  61115. * @param onError is a callback called if an error occurs
  61116. */
  61117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61118. }
  61119. /**
  61120. * Define a task used by AssetsManager to load HDR cube textures
  61121. */
  61122. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61123. /**
  61124. * Defines the name of the task
  61125. */
  61126. name: string;
  61127. /**
  61128. * Defines the location of the file to load
  61129. */
  61130. url: string;
  61131. /**
  61132. * Defines the desired size (the more it increases the longer the generation will be)
  61133. */
  61134. size: number;
  61135. /**
  61136. * Defines if mipmaps should not be generated (default is false)
  61137. */
  61138. noMipmap: boolean;
  61139. /**
  61140. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61141. */
  61142. generateHarmonics: boolean;
  61143. /**
  61144. * 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)
  61145. */
  61146. gammaSpace: boolean;
  61147. /**
  61148. * Internal Use Only
  61149. */
  61150. reserved: boolean;
  61151. /**
  61152. * Gets the loaded texture
  61153. */
  61154. texture: HDRCubeTexture;
  61155. /**
  61156. * Callback called when the task is successful
  61157. */
  61158. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61159. /**
  61160. * Callback called when the task is successful
  61161. */
  61162. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61163. /**
  61164. * Creates a new HDRCubeTextureAssetTask object
  61165. * @param name defines the name of the task
  61166. * @param url defines the location of the file to load
  61167. * @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.
  61168. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61169. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61170. * @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)
  61171. * @param reserved Internal use only
  61172. */
  61173. constructor(
  61174. /**
  61175. * Defines the name of the task
  61176. */
  61177. name: string,
  61178. /**
  61179. * Defines the location of the file to load
  61180. */
  61181. url: string,
  61182. /**
  61183. * Defines the desired size (the more it increases the longer the generation will be)
  61184. */
  61185. size: number,
  61186. /**
  61187. * Defines if mipmaps should not be generated (default is false)
  61188. */
  61189. noMipmap?: boolean,
  61190. /**
  61191. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61192. */
  61193. generateHarmonics?: boolean,
  61194. /**
  61195. * 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)
  61196. */
  61197. gammaSpace?: boolean,
  61198. /**
  61199. * Internal Use Only
  61200. */
  61201. reserved?: boolean);
  61202. /**
  61203. * Execute the current task
  61204. * @param scene defines the scene where you want your assets to be loaded
  61205. * @param onSuccess is a callback called when the task is successfully executed
  61206. * @param onError is a callback called if an error occurs
  61207. */
  61208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61209. }
  61210. /**
  61211. * Define a task used by AssetsManager to load Equirectangular cube textures
  61212. */
  61213. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61214. /**
  61215. * Defines the name of the task
  61216. */
  61217. name: string;
  61218. /**
  61219. * Defines the location of the file to load
  61220. */
  61221. url: string;
  61222. /**
  61223. * Defines the desired size (the more it increases the longer the generation will be)
  61224. */
  61225. size: number;
  61226. /**
  61227. * Defines if mipmaps should not be generated (default is false)
  61228. */
  61229. noMipmap: boolean;
  61230. /**
  61231. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61232. * but the standard material would require them in Gamma space) (default is true)
  61233. */
  61234. gammaSpace: boolean;
  61235. /**
  61236. * Gets the loaded texture
  61237. */
  61238. texture: EquiRectangularCubeTexture;
  61239. /**
  61240. * Callback called when the task is successful
  61241. */
  61242. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61243. /**
  61244. * Callback called when the task is successful
  61245. */
  61246. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61247. /**
  61248. * Creates a new EquiRectangularCubeTextureAssetTask object
  61249. * @param name defines the name of the task
  61250. * @param url defines the location of the file to load
  61251. * @param size defines the desired size (the more it increases the longer the generation will be)
  61252. * If the size is omitted this implies you are using a preprocessed cubemap.
  61253. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61254. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61255. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61256. * (default is true)
  61257. */
  61258. constructor(
  61259. /**
  61260. * Defines the name of the task
  61261. */
  61262. name: string,
  61263. /**
  61264. * Defines the location of the file to load
  61265. */
  61266. url: string,
  61267. /**
  61268. * Defines the desired size (the more it increases the longer the generation will be)
  61269. */
  61270. size: number,
  61271. /**
  61272. * Defines if mipmaps should not be generated (default is false)
  61273. */
  61274. noMipmap?: boolean,
  61275. /**
  61276. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61277. * but the standard material would require them in Gamma space) (default is true)
  61278. */
  61279. gammaSpace?: boolean);
  61280. /**
  61281. * Execute the current task
  61282. * @param scene defines the scene where you want your assets to be loaded
  61283. * @param onSuccess is a callback called when the task is successfully executed
  61284. * @param onError is a callback called if an error occurs
  61285. */
  61286. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61287. }
  61288. /**
  61289. * This class can be used to easily import assets into a scene
  61290. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61291. */
  61292. export class AssetsManager {
  61293. private _scene;
  61294. private _isLoading;
  61295. protected _tasks: AbstractAssetTask[];
  61296. protected _waitingTasksCount: number;
  61297. protected _totalTasksCount: number;
  61298. /**
  61299. * Callback called when all tasks are processed
  61300. */
  61301. onFinish: (tasks: AbstractAssetTask[]) => void;
  61302. /**
  61303. * Callback called when a task is successful
  61304. */
  61305. onTaskSuccess: (task: AbstractAssetTask) => void;
  61306. /**
  61307. * Callback called when a task had an error
  61308. */
  61309. onTaskError: (task: AbstractAssetTask) => void;
  61310. /**
  61311. * Callback called when a task is done (whatever the result is)
  61312. */
  61313. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61314. /**
  61315. * Observable called when all tasks are processed
  61316. */
  61317. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61318. /**
  61319. * Observable called when a task had an error
  61320. */
  61321. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61322. /**
  61323. * Observable called when all tasks were executed
  61324. */
  61325. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61326. /**
  61327. * Observable called when a task is done (whatever the result is)
  61328. */
  61329. onProgressObservable: Observable<IAssetsProgressEvent>;
  61330. /**
  61331. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61333. */
  61334. useDefaultLoadingScreen: boolean;
  61335. /**
  61336. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61337. * when all assets have been downloaded.
  61338. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61339. */
  61340. autoHideLoadingUI: boolean;
  61341. /**
  61342. * Creates a new AssetsManager
  61343. * @param scene defines the scene to work on
  61344. */
  61345. constructor(scene: Scene);
  61346. /**
  61347. * Add a MeshAssetTask to the list of active tasks
  61348. * @param taskName defines the name of the new task
  61349. * @param meshesNames defines the name of meshes to load
  61350. * @param rootUrl defines the root url to use to locate files
  61351. * @param sceneFilename defines the filename of the scene file
  61352. * @returns a new MeshAssetTask object
  61353. */
  61354. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61355. /**
  61356. * Add a TextFileAssetTask to the list of active tasks
  61357. * @param taskName defines the name of the new task
  61358. * @param url defines the url of the file to load
  61359. * @returns a new TextFileAssetTask object
  61360. */
  61361. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61362. /**
  61363. * Add a BinaryFileAssetTask to the list of active tasks
  61364. * @param taskName defines the name of the new task
  61365. * @param url defines the url of the file to load
  61366. * @returns a new BinaryFileAssetTask object
  61367. */
  61368. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61369. /**
  61370. * Add a ImageAssetTask to the list of active tasks
  61371. * @param taskName defines the name of the new task
  61372. * @param url defines the url of the file to load
  61373. * @returns a new ImageAssetTask object
  61374. */
  61375. addImageTask(taskName: string, url: string): ImageAssetTask;
  61376. /**
  61377. * Add a TextureAssetTask to the list of active tasks
  61378. * @param taskName defines the name of the new task
  61379. * @param url defines the url of the file to load
  61380. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61381. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61382. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61383. * @returns a new TextureAssetTask object
  61384. */
  61385. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61386. /**
  61387. * Add a CubeTextureAssetTask to the list of active tasks
  61388. * @param taskName defines the name of the new task
  61389. * @param url defines the url of the file to load
  61390. * @param extensions defines the extension to use to load the cube map (can be null)
  61391. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61392. * @param files defines the list of files to load (can be null)
  61393. * @returns a new CubeTextureAssetTask object
  61394. */
  61395. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61396. /**
  61397. *
  61398. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61399. * @param taskName defines the name of the new task
  61400. * @param url defines the url of the file to load
  61401. * @param size defines the size you want for the cubemap (can be null)
  61402. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61403. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61404. * @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)
  61405. * @param reserved Internal use only
  61406. * @returns a new HDRCubeTextureAssetTask object
  61407. */
  61408. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61409. /**
  61410. *
  61411. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61412. * @param taskName defines the name of the new task
  61413. * @param url defines the url of the file to load
  61414. * @param size defines the size you want for the cubemap (can be null)
  61415. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61416. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61417. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61418. * @returns a new EquiRectangularCubeTextureAssetTask object
  61419. */
  61420. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61421. /**
  61422. * Remove a task from the assets manager.
  61423. * @param task the task to remove
  61424. */
  61425. removeTask(task: AbstractAssetTask): void;
  61426. private _decreaseWaitingTasksCount;
  61427. private _runTask;
  61428. /**
  61429. * Reset the AssetsManager and remove all tasks
  61430. * @return the current instance of the AssetsManager
  61431. */
  61432. reset(): AssetsManager;
  61433. /**
  61434. * Start the loading process
  61435. * @return the current instance of the AssetsManager
  61436. */
  61437. load(): AssetsManager;
  61438. /**
  61439. * Start the loading process as an async operation
  61440. * @return a promise returning the list of failed tasks
  61441. */
  61442. loadAsync(): Promise<void>;
  61443. }
  61444. }
  61445. declare module BABYLON {
  61446. /**
  61447. * Wrapper class for promise with external resolve and reject.
  61448. */
  61449. export class Deferred<T> {
  61450. /**
  61451. * The promise associated with this deferred object.
  61452. */
  61453. readonly promise: Promise<T>;
  61454. private _resolve;
  61455. private _reject;
  61456. /**
  61457. * The resolve method of the promise associated with this deferred object.
  61458. */
  61459. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61460. /**
  61461. * The reject method of the promise associated with this deferred object.
  61462. */
  61463. readonly reject: (reason?: any) => void;
  61464. /**
  61465. * Constructor for this deferred object.
  61466. */
  61467. constructor();
  61468. }
  61469. }
  61470. declare module BABYLON {
  61471. /**
  61472. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61473. */
  61474. export class MeshExploder {
  61475. private _centerMesh;
  61476. private _meshes;
  61477. private _meshesOrigins;
  61478. private _toCenterVectors;
  61479. private _scaledDirection;
  61480. private _newPosition;
  61481. private _centerPosition;
  61482. /**
  61483. * Explodes meshes from a center mesh.
  61484. * @param meshes The meshes to explode.
  61485. * @param centerMesh The mesh to be center of explosion.
  61486. */
  61487. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61488. private _setCenterMesh;
  61489. /**
  61490. * Get class name
  61491. * @returns "MeshExploder"
  61492. */
  61493. getClassName(): string;
  61494. /**
  61495. * "Exploded meshes"
  61496. * @returns Array of meshes with the centerMesh at index 0.
  61497. */
  61498. getMeshes(): Array<Mesh>;
  61499. /**
  61500. * Explodes meshes giving a specific direction
  61501. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61502. */
  61503. explode(direction?: number): void;
  61504. }
  61505. }
  61506. declare module BABYLON {
  61507. /**
  61508. * Class used to help managing file picking and drag'n'drop
  61509. */
  61510. export class FilesInput {
  61511. /**
  61512. * List of files ready to be loaded
  61513. */
  61514. static readonly FilesToLoad: {
  61515. [key: string]: File;
  61516. };
  61517. /**
  61518. * Callback called when a file is processed
  61519. */
  61520. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61521. private _engine;
  61522. private _currentScene;
  61523. private _sceneLoadedCallback;
  61524. private _progressCallback;
  61525. private _additionalRenderLoopLogicCallback;
  61526. private _textureLoadingCallback;
  61527. private _startingProcessingFilesCallback;
  61528. private _onReloadCallback;
  61529. private _errorCallback;
  61530. private _elementToMonitor;
  61531. private _sceneFileToLoad;
  61532. private _filesToLoad;
  61533. /**
  61534. * Creates a new FilesInput
  61535. * @param engine defines the rendering engine
  61536. * @param scene defines the hosting scene
  61537. * @param sceneLoadedCallback callback called when scene is loaded
  61538. * @param progressCallback callback called to track progress
  61539. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61540. * @param textureLoadingCallback callback called when a texture is loading
  61541. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61542. * @param onReloadCallback callback called when a reload is requested
  61543. * @param errorCallback callback call if an error occurs
  61544. */
  61545. 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);
  61546. private _dragEnterHandler;
  61547. private _dragOverHandler;
  61548. private _dropHandler;
  61549. /**
  61550. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61551. * @param elementToMonitor defines the DOM element to track
  61552. */
  61553. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61554. /**
  61555. * Release all associated resources
  61556. */
  61557. dispose(): void;
  61558. private renderFunction;
  61559. private drag;
  61560. private drop;
  61561. private _traverseFolder;
  61562. private _processFiles;
  61563. /**
  61564. * Load files from a drop event
  61565. * @param event defines the drop event to use as source
  61566. */
  61567. loadFiles(event: any): void;
  61568. private _processReload;
  61569. /**
  61570. * Reload the current scene from the loaded files
  61571. */
  61572. reload(): void;
  61573. }
  61574. }
  61575. declare module BABYLON {
  61576. /**
  61577. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61579. */
  61580. export class SceneOptimization {
  61581. /**
  61582. * Defines the priority of this optimization (0 by default which means first in the list)
  61583. */
  61584. priority: number;
  61585. /**
  61586. * Gets a string describing the action executed by the current optimization
  61587. * @returns description string
  61588. */
  61589. getDescription(): string;
  61590. /**
  61591. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61592. * @param scene defines the current scene where to apply this optimization
  61593. * @param optimizer defines the current optimizer
  61594. * @returns true if everything that can be done was applied
  61595. */
  61596. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61597. /**
  61598. * Creates the SceneOptimization object
  61599. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61600. * @param desc defines the description associated with the optimization
  61601. */
  61602. constructor(
  61603. /**
  61604. * Defines the priority of this optimization (0 by default which means first in the list)
  61605. */
  61606. priority?: number);
  61607. }
  61608. /**
  61609. * Defines an optimization used to reduce the size of render target textures
  61610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61611. */
  61612. export class TextureOptimization extends SceneOptimization {
  61613. /**
  61614. * Defines the priority of this optimization (0 by default which means first in the list)
  61615. */
  61616. priority: number;
  61617. /**
  61618. * 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
  61619. */
  61620. maximumSize: number;
  61621. /**
  61622. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61623. */
  61624. step: number;
  61625. /**
  61626. * Gets a string describing the action executed by the current optimization
  61627. * @returns description string
  61628. */
  61629. getDescription(): string;
  61630. /**
  61631. * Creates the TextureOptimization object
  61632. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61633. * @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
  61634. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61635. */
  61636. constructor(
  61637. /**
  61638. * Defines the priority of this optimization (0 by default which means first in the list)
  61639. */
  61640. priority?: number,
  61641. /**
  61642. * 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
  61643. */
  61644. maximumSize?: number,
  61645. /**
  61646. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61647. */
  61648. step?: number);
  61649. /**
  61650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61651. * @param scene defines the current scene where to apply this optimization
  61652. * @param optimizer defines the current optimizer
  61653. * @returns true if everything that can be done was applied
  61654. */
  61655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61656. }
  61657. /**
  61658. * Defines an optimization used to increase or decrease the rendering resolution
  61659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61660. */
  61661. export class HardwareScalingOptimization extends SceneOptimization {
  61662. /**
  61663. * Defines the priority of this optimization (0 by default which means first in the list)
  61664. */
  61665. priority: number;
  61666. /**
  61667. * Defines the maximum scale to use (2 by default)
  61668. */
  61669. maximumScale: number;
  61670. /**
  61671. * Defines the step to use between two passes (0.5 by default)
  61672. */
  61673. step: number;
  61674. private _currentScale;
  61675. private _directionOffset;
  61676. /**
  61677. * Gets a string describing the action executed by the current optimization
  61678. * @return description string
  61679. */
  61680. getDescription(): string;
  61681. /**
  61682. * Creates the HardwareScalingOptimization object
  61683. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61684. * @param maximumScale defines the maximum scale to use (2 by default)
  61685. * @param step defines the step to use between two passes (0.5 by default)
  61686. */
  61687. constructor(
  61688. /**
  61689. * Defines the priority of this optimization (0 by default which means first in the list)
  61690. */
  61691. priority?: number,
  61692. /**
  61693. * Defines the maximum scale to use (2 by default)
  61694. */
  61695. maximumScale?: number,
  61696. /**
  61697. * Defines the step to use between two passes (0.5 by default)
  61698. */
  61699. step?: number);
  61700. /**
  61701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61702. * @param scene defines the current scene where to apply this optimization
  61703. * @param optimizer defines the current optimizer
  61704. * @returns true if everything that can be done was applied
  61705. */
  61706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61707. }
  61708. /**
  61709. * Defines an optimization used to remove shadows
  61710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61711. */
  61712. export class ShadowsOptimization extends SceneOptimization {
  61713. /**
  61714. * Gets a string describing the action executed by the current optimization
  61715. * @return description string
  61716. */
  61717. getDescription(): string;
  61718. /**
  61719. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61720. * @param scene defines the current scene where to apply this optimization
  61721. * @param optimizer defines the current optimizer
  61722. * @returns true if everything that can be done was applied
  61723. */
  61724. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61725. }
  61726. /**
  61727. * Defines an optimization used to turn post-processes off
  61728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61729. */
  61730. export class PostProcessesOptimization extends SceneOptimization {
  61731. /**
  61732. * Gets a string describing the action executed by the current optimization
  61733. * @return description string
  61734. */
  61735. getDescription(): string;
  61736. /**
  61737. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61738. * @param scene defines the current scene where to apply this optimization
  61739. * @param optimizer defines the current optimizer
  61740. * @returns true if everything that can be done was applied
  61741. */
  61742. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61743. }
  61744. /**
  61745. * Defines an optimization used to turn lens flares off
  61746. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61747. */
  61748. export class LensFlaresOptimization extends SceneOptimization {
  61749. /**
  61750. * Gets a string describing the action executed by the current optimization
  61751. * @return description string
  61752. */
  61753. getDescription(): string;
  61754. /**
  61755. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61756. * @param scene defines the current scene where to apply this optimization
  61757. * @param optimizer defines the current optimizer
  61758. * @returns true if everything that can be done was applied
  61759. */
  61760. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61761. }
  61762. /**
  61763. * Defines an optimization based on user defined callback.
  61764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61765. */
  61766. export class CustomOptimization extends SceneOptimization {
  61767. /**
  61768. * Callback called to apply the custom optimization.
  61769. */
  61770. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61771. /**
  61772. * Callback called to get custom description
  61773. */
  61774. onGetDescription: () => string;
  61775. /**
  61776. * Gets a string describing the action executed by the current optimization
  61777. * @returns description string
  61778. */
  61779. getDescription(): string;
  61780. /**
  61781. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61782. * @param scene defines the current scene where to apply this optimization
  61783. * @param optimizer defines the current optimizer
  61784. * @returns true if everything that can be done was applied
  61785. */
  61786. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61787. }
  61788. /**
  61789. * Defines an optimization used to turn particles off
  61790. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61791. */
  61792. export class ParticlesOptimization extends SceneOptimization {
  61793. /**
  61794. * Gets a string describing the action executed by the current optimization
  61795. * @return description string
  61796. */
  61797. getDescription(): string;
  61798. /**
  61799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61800. * @param scene defines the current scene where to apply this optimization
  61801. * @param optimizer defines the current optimizer
  61802. * @returns true if everything that can be done was applied
  61803. */
  61804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61805. }
  61806. /**
  61807. * Defines an optimization used to turn render targets off
  61808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61809. */
  61810. export class RenderTargetsOptimization extends SceneOptimization {
  61811. /**
  61812. * Gets a string describing the action executed by the current optimization
  61813. * @return description string
  61814. */
  61815. getDescription(): string;
  61816. /**
  61817. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61818. * @param scene defines the current scene where to apply this optimization
  61819. * @param optimizer defines the current optimizer
  61820. * @returns true if everything that can be done was applied
  61821. */
  61822. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61823. }
  61824. /**
  61825. * Defines an optimization used to merge meshes with compatible materials
  61826. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61827. */
  61828. export class MergeMeshesOptimization extends SceneOptimization {
  61829. private static _UpdateSelectionTree;
  61830. /**
  61831. * Gets or sets a boolean which defines if optimization octree has to be updated
  61832. */
  61833. /**
  61834. * Gets or sets a boolean which defines if optimization octree has to be updated
  61835. */
  61836. static UpdateSelectionTree: boolean;
  61837. /**
  61838. * Gets a string describing the action executed by the current optimization
  61839. * @return description string
  61840. */
  61841. getDescription(): string;
  61842. private _canBeMerged;
  61843. /**
  61844. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61845. * @param scene defines the current scene where to apply this optimization
  61846. * @param optimizer defines the current optimizer
  61847. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61848. * @returns true if everything that can be done was applied
  61849. */
  61850. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61851. }
  61852. /**
  61853. * Defines a list of options used by SceneOptimizer
  61854. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61855. */
  61856. export class SceneOptimizerOptions {
  61857. /**
  61858. * Defines the target frame rate to reach (60 by default)
  61859. */
  61860. targetFrameRate: number;
  61861. /**
  61862. * Defines the interval between two checkes (2000ms by default)
  61863. */
  61864. trackerDuration: number;
  61865. /**
  61866. * Gets the list of optimizations to apply
  61867. */
  61868. optimizations: SceneOptimization[];
  61869. /**
  61870. * Creates a new list of options used by SceneOptimizer
  61871. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61872. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61873. */
  61874. constructor(
  61875. /**
  61876. * Defines the target frame rate to reach (60 by default)
  61877. */
  61878. targetFrameRate?: number,
  61879. /**
  61880. * Defines the interval between two checkes (2000ms by default)
  61881. */
  61882. trackerDuration?: number);
  61883. /**
  61884. * Add a new optimization
  61885. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61886. * @returns the current SceneOptimizerOptions
  61887. */
  61888. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61889. /**
  61890. * Add a new custom optimization
  61891. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61892. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61893. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61894. * @returns the current SceneOptimizerOptions
  61895. */
  61896. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61897. /**
  61898. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61899. * @param targetFrameRate defines the target frame rate (60 by default)
  61900. * @returns a SceneOptimizerOptions object
  61901. */
  61902. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61903. /**
  61904. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61905. * @param targetFrameRate defines the target frame rate (60 by default)
  61906. * @returns a SceneOptimizerOptions object
  61907. */
  61908. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61909. /**
  61910. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61911. * @param targetFrameRate defines the target frame rate (60 by default)
  61912. * @returns a SceneOptimizerOptions object
  61913. */
  61914. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61915. }
  61916. /**
  61917. * Class used to run optimizations in order to reach a target frame rate
  61918. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61919. */
  61920. export class SceneOptimizer implements IDisposable {
  61921. private _isRunning;
  61922. private _options;
  61923. private _scene;
  61924. private _currentPriorityLevel;
  61925. private _targetFrameRate;
  61926. private _trackerDuration;
  61927. private _currentFrameRate;
  61928. private _sceneDisposeObserver;
  61929. private _improvementMode;
  61930. /**
  61931. * Defines an observable called when the optimizer reaches the target frame rate
  61932. */
  61933. onSuccessObservable: Observable<SceneOptimizer>;
  61934. /**
  61935. * Defines an observable called when the optimizer enables an optimization
  61936. */
  61937. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61938. /**
  61939. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61940. */
  61941. onFailureObservable: Observable<SceneOptimizer>;
  61942. /**
  61943. * Gets a boolean indicating if the optimizer is in improvement mode
  61944. */
  61945. readonly isInImprovementMode: boolean;
  61946. /**
  61947. * Gets the current priority level (0 at start)
  61948. */
  61949. readonly currentPriorityLevel: number;
  61950. /**
  61951. * Gets the current frame rate checked by the SceneOptimizer
  61952. */
  61953. readonly currentFrameRate: number;
  61954. /**
  61955. * Gets or sets the current target frame rate (60 by default)
  61956. */
  61957. /**
  61958. * Gets or sets the current target frame rate (60 by default)
  61959. */
  61960. targetFrameRate: number;
  61961. /**
  61962. * Gets or sets the current interval between two checks (every 2000ms by default)
  61963. */
  61964. /**
  61965. * Gets or sets the current interval between two checks (every 2000ms by default)
  61966. */
  61967. trackerDuration: number;
  61968. /**
  61969. * Gets the list of active optimizations
  61970. */
  61971. readonly optimizations: SceneOptimization[];
  61972. /**
  61973. * Creates a new SceneOptimizer
  61974. * @param scene defines the scene to work on
  61975. * @param options defines the options to use with the SceneOptimizer
  61976. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61977. * @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)
  61978. */
  61979. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61980. /**
  61981. * Stops the current optimizer
  61982. */
  61983. stop(): void;
  61984. /**
  61985. * Reset the optimizer to initial step (current priority level = 0)
  61986. */
  61987. reset(): void;
  61988. /**
  61989. * Start the optimizer. By default it will try to reach a specific framerate
  61990. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61991. */
  61992. start(): void;
  61993. private _checkCurrentState;
  61994. /**
  61995. * Release all resources
  61996. */
  61997. dispose(): void;
  61998. /**
  61999. * Helper function to create a SceneOptimizer with one single line of code
  62000. * @param scene defines the scene to work on
  62001. * @param options defines the options to use with the SceneOptimizer
  62002. * @param onSuccess defines a callback to call on success
  62003. * @param onFailure defines a callback to call on failure
  62004. * @returns the new SceneOptimizer object
  62005. */
  62006. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62007. }
  62008. }
  62009. declare module BABYLON {
  62010. /**
  62011. * Class used to serialize a scene into a string
  62012. */
  62013. export class SceneSerializer {
  62014. /**
  62015. * Clear cache used by a previous serialization
  62016. */
  62017. static ClearCache(): void;
  62018. /**
  62019. * Serialize a scene into a JSON compatible object
  62020. * @param scene defines the scene to serialize
  62021. * @returns a JSON compatible object
  62022. */
  62023. static Serialize(scene: Scene): any;
  62024. /**
  62025. * Serialize a mesh into a JSON compatible object
  62026. * @param toSerialize defines the mesh to serialize
  62027. * @param withParents defines if parents must be serialized as well
  62028. * @param withChildren defines if children must be serialized as well
  62029. * @returns a JSON compatible object
  62030. */
  62031. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62032. }
  62033. }
  62034. declare module BABYLON {
  62035. /**
  62036. * Class used to host texture specific utilities
  62037. */
  62038. export class TextureTools {
  62039. /**
  62040. * Uses the GPU to create a copy texture rescaled at a given size
  62041. * @param texture Texture to copy from
  62042. * @param width defines the desired width
  62043. * @param height defines the desired height
  62044. * @param useBilinearMode defines if bilinear mode has to be used
  62045. * @return the generated texture
  62046. */
  62047. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62048. }
  62049. }
  62050. declare module BABYLON {
  62051. /**
  62052. * This represents the different options available for the video capture.
  62053. */
  62054. export interface VideoRecorderOptions {
  62055. /** Defines the mime type of the video. */
  62056. mimeType: string;
  62057. /** Defines the FPS the video should be recorded at. */
  62058. fps: number;
  62059. /** Defines the chunk size for the recording data. */
  62060. recordChunckSize: number;
  62061. /** The audio tracks to attach to the recording. */
  62062. audioTracks?: MediaStreamTrack[];
  62063. }
  62064. /**
  62065. * This can help with recording videos from BabylonJS.
  62066. * This is based on the available WebRTC functionalities of the browser.
  62067. *
  62068. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62069. */
  62070. export class VideoRecorder {
  62071. private static readonly _defaultOptions;
  62072. /**
  62073. * Returns whether or not the VideoRecorder is available in your browser.
  62074. * @param engine Defines the Babylon Engine.
  62075. * @returns true if supported otherwise false.
  62076. */
  62077. static IsSupported(engine: Engine): boolean;
  62078. private readonly _options;
  62079. private _canvas;
  62080. private _mediaRecorder;
  62081. private _recordedChunks;
  62082. private _fileName;
  62083. private _resolve;
  62084. private _reject;
  62085. /**
  62086. * True when a recording is already in progress.
  62087. */
  62088. readonly isRecording: boolean;
  62089. /**
  62090. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62091. * @param engine Defines the BabylonJS Engine you wish to record.
  62092. * @param options Defines options that can be used to customize the capture.
  62093. */
  62094. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62095. /**
  62096. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62097. */
  62098. stopRecording(): void;
  62099. /**
  62100. * Starts recording the canvas for a max duration specified in parameters.
  62101. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62102. * If null no automatic download will start and you can rely on the promise to get the data back.
  62103. * @param maxDuration Defines the maximum recording time in seconds.
  62104. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62105. * @return A promise callback at the end of the recording with the video data in Blob.
  62106. */
  62107. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62108. /**
  62109. * Releases internal resources used during the recording.
  62110. */
  62111. dispose(): void;
  62112. private _handleDataAvailable;
  62113. private _handleError;
  62114. private _handleStop;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Class containing a set of static utilities functions for screenshots
  62120. */
  62121. export class ScreenshotTools {
  62122. /**
  62123. * Captures a screenshot of the current rendering
  62124. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62125. * @param engine defines the rendering engine
  62126. * @param camera defines the source camera
  62127. * @param size This parameter can be set to a single number or to an object with the
  62128. * following (optional) properties: precision, width, height. If a single number is passed,
  62129. * it will be used for both width and height. If an object is passed, the screenshot size
  62130. * will be derived from the parameters. The precision property is a multiplier allowing
  62131. * rendering at a higher or lower resolution
  62132. * @param successCallback defines the callback receives a single parameter which contains the
  62133. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62134. * src parameter of an <img> to display it
  62135. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62136. * Check your browser for supported MIME types
  62137. */
  62138. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62139. /**
  62140. * Captures a screenshot of the current rendering
  62141. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62142. * @param engine defines the rendering engine
  62143. * @param camera defines the source camera
  62144. * @param size This parameter can be set to a single number or to an object with the
  62145. * following (optional) properties: precision, width, height. If a single number is passed,
  62146. * it will be used for both width and height. If an object is passed, the screenshot size
  62147. * will be derived from the parameters. The precision property is a multiplier allowing
  62148. * rendering at a higher or lower resolution
  62149. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62150. * Check your browser for supported MIME types
  62151. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62152. * to the src parameter of an <img> to display it
  62153. */
  62154. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62155. /**
  62156. * Generates an image screenshot from the specified camera.
  62157. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62158. * @param engine The engine to use for rendering
  62159. * @param camera The camera to use for rendering
  62160. * @param size This parameter can be set to a single number or to an object with the
  62161. * following (optional) properties: precision, width, height. If a single number is passed,
  62162. * it will be used for both width and height. If an object is passed, the screenshot size
  62163. * will be derived from the parameters. The precision property is a multiplier allowing
  62164. * rendering at a higher or lower resolution
  62165. * @param successCallback The callback receives a single parameter which contains the
  62166. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62167. * src parameter of an <img> to display it
  62168. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62169. * Check your browser for supported MIME types
  62170. * @param samples Texture samples (default: 1)
  62171. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62172. * @param fileName A name for for the downloaded file.
  62173. */
  62174. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62175. /**
  62176. * Generates an image screenshot from the specified camera.
  62177. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62178. * @param engine The engine to use for rendering
  62179. * @param camera The camera to use for rendering
  62180. * @param size This parameter can be set to a single number or to an object with the
  62181. * following (optional) properties: precision, width, height. If a single number is passed,
  62182. * it will be used for both width and height. If an object is passed, the screenshot size
  62183. * will be derived from the parameters. The precision property is a multiplier allowing
  62184. * rendering at a higher or lower resolution
  62185. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62186. * Check your browser for supported MIME types
  62187. * @param samples Texture samples (default: 1)
  62188. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62189. * @param fileName A name for for the downloaded file.
  62190. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62191. * to the src parameter of an <img> to display it
  62192. */
  62193. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62194. /**
  62195. * Gets height and width for screenshot size
  62196. * @private
  62197. */
  62198. private static _getScreenshotSize;
  62199. }
  62200. }
  62201. declare module BABYLON {
  62202. /**
  62203. * A cursor which tracks a point on a path
  62204. */
  62205. export class PathCursor {
  62206. private path;
  62207. /**
  62208. * Stores path cursor callbacks for when an onchange event is triggered
  62209. */
  62210. private _onchange;
  62211. /**
  62212. * The value of the path cursor
  62213. */
  62214. value: number;
  62215. /**
  62216. * The animation array of the path cursor
  62217. */
  62218. animations: Animation[];
  62219. /**
  62220. * Initializes the path cursor
  62221. * @param path The path to track
  62222. */
  62223. constructor(path: Path2);
  62224. /**
  62225. * Gets the cursor point on the path
  62226. * @returns A point on the path cursor at the cursor location
  62227. */
  62228. getPoint(): Vector3;
  62229. /**
  62230. * Moves the cursor ahead by the step amount
  62231. * @param step The amount to move the cursor forward
  62232. * @returns This path cursor
  62233. */
  62234. moveAhead(step?: number): PathCursor;
  62235. /**
  62236. * Moves the cursor behind by the step amount
  62237. * @param step The amount to move the cursor back
  62238. * @returns This path cursor
  62239. */
  62240. moveBack(step?: number): PathCursor;
  62241. /**
  62242. * Moves the cursor by the step amount
  62243. * If the step amount is greater than one, an exception is thrown
  62244. * @param step The amount to move the cursor
  62245. * @returns This path cursor
  62246. */
  62247. move(step: number): PathCursor;
  62248. /**
  62249. * Ensures that the value is limited between zero and one
  62250. * @returns This path cursor
  62251. */
  62252. private ensureLimits;
  62253. /**
  62254. * Runs onchange callbacks on change (used by the animation engine)
  62255. * @returns This path cursor
  62256. */
  62257. private raiseOnChange;
  62258. /**
  62259. * Executes a function on change
  62260. * @param f A path cursor onchange callback
  62261. * @returns This path cursor
  62262. */
  62263. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /** @hidden */
  62268. export var blurPixelShader: {
  62269. name: string;
  62270. shader: string;
  62271. };
  62272. }
  62273. declare module BABYLON {
  62274. /** @hidden */
  62275. export var pointCloudVertexDeclaration: {
  62276. name: string;
  62277. shader: string;
  62278. };
  62279. }
  62280. // Mixins
  62281. interface Window {
  62282. mozIndexedDB: IDBFactory;
  62283. webkitIndexedDB: IDBFactory;
  62284. msIndexedDB: IDBFactory;
  62285. webkitURL: typeof URL;
  62286. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62287. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62288. WebGLRenderingContext: WebGLRenderingContext;
  62289. MSGesture: MSGesture;
  62290. CANNON: any;
  62291. AudioContext: AudioContext;
  62292. webkitAudioContext: AudioContext;
  62293. PointerEvent: any;
  62294. Math: Math;
  62295. Uint8Array: Uint8ArrayConstructor;
  62296. Float32Array: Float32ArrayConstructor;
  62297. mozURL: typeof URL;
  62298. msURL: typeof URL;
  62299. VRFrameData: any; // WebVR, from specs 1.1
  62300. DracoDecoderModule: any;
  62301. setImmediate(handler: (...args: any[]) => void): number;
  62302. }
  62303. interface HTMLCanvasElement {
  62304. requestPointerLock(): void;
  62305. msRequestPointerLock?(): void;
  62306. mozRequestPointerLock?(): void;
  62307. webkitRequestPointerLock?(): void;
  62308. /** Track wether a record is in progress */
  62309. isRecording: boolean;
  62310. /** Capture Stream method defined by some browsers */
  62311. captureStream(fps?: number): MediaStream;
  62312. }
  62313. interface CanvasRenderingContext2D {
  62314. msImageSmoothingEnabled: boolean;
  62315. }
  62316. interface MouseEvent {
  62317. mozMovementX: number;
  62318. mozMovementY: number;
  62319. webkitMovementX: number;
  62320. webkitMovementY: number;
  62321. msMovementX: number;
  62322. msMovementY: number;
  62323. }
  62324. interface Navigator {
  62325. mozGetVRDevices: (any: any) => any;
  62326. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62327. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62328. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62329. webkitGetGamepads(): Gamepad[];
  62330. msGetGamepads(): Gamepad[];
  62331. webkitGamepads(): Gamepad[];
  62332. }
  62333. interface HTMLVideoElement {
  62334. mozSrcObject: any;
  62335. }
  62336. interface Math {
  62337. fround(x: number): number;
  62338. imul(a: number, b: number): number;
  62339. }
  62340. interface WebGLRenderingContext {
  62341. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62342. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62343. vertexAttribDivisor(index: number, divisor: number): void;
  62344. createVertexArray(): any;
  62345. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62346. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62347. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62348. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62349. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62350. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62351. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62352. // Queries
  62353. createQuery(): WebGLQuery;
  62354. deleteQuery(query: WebGLQuery): void;
  62355. beginQuery(target: number, query: WebGLQuery): void;
  62356. endQuery(target: number): void;
  62357. getQueryParameter(query: WebGLQuery, pname: number): any;
  62358. getQuery(target: number, pname: number): any;
  62359. MAX_SAMPLES: number;
  62360. RGBA8: number;
  62361. READ_FRAMEBUFFER: number;
  62362. DRAW_FRAMEBUFFER: number;
  62363. UNIFORM_BUFFER: number;
  62364. HALF_FLOAT_OES: number;
  62365. RGBA16F: number;
  62366. RGBA32F: number;
  62367. R32F: number;
  62368. RG32F: number;
  62369. RGB32F: number;
  62370. R16F: number;
  62371. RG16F: number;
  62372. RGB16F: number;
  62373. RED: number;
  62374. RG: number;
  62375. R8: number;
  62376. RG8: number;
  62377. UNSIGNED_INT_24_8: number;
  62378. DEPTH24_STENCIL8: number;
  62379. /* Multiple Render Targets */
  62380. drawBuffers(buffers: number[]): void;
  62381. readBuffer(src: number): void;
  62382. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62383. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62384. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62385. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62386. // Occlusion Query
  62387. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62388. ANY_SAMPLES_PASSED: number;
  62389. QUERY_RESULT_AVAILABLE: number;
  62390. QUERY_RESULT: number;
  62391. }
  62392. interface WebGLProgram {
  62393. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62394. }
  62395. interface EXT_disjoint_timer_query {
  62396. QUERY_COUNTER_BITS_EXT: number;
  62397. TIME_ELAPSED_EXT: number;
  62398. TIMESTAMP_EXT: number;
  62399. GPU_DISJOINT_EXT: number;
  62400. QUERY_RESULT_EXT: number;
  62401. QUERY_RESULT_AVAILABLE_EXT: number;
  62402. queryCounterEXT(query: WebGLQuery, target: number): void;
  62403. createQueryEXT(): WebGLQuery;
  62404. beginQueryEXT(target: number, query: WebGLQuery): void;
  62405. endQueryEXT(target: number): void;
  62406. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62407. deleteQueryEXT(query: WebGLQuery): void;
  62408. }
  62409. interface WebGLUniformLocation {
  62410. _currentState: any;
  62411. }
  62412. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62413. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62414. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62415. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62416. interface WebGLRenderingContext {
  62417. readonly RASTERIZER_DISCARD: number;
  62418. readonly DEPTH_COMPONENT24: number;
  62419. readonly TEXTURE_3D: number;
  62420. readonly TEXTURE_2D_ARRAY: number;
  62421. readonly TEXTURE_COMPARE_FUNC: number;
  62422. readonly TEXTURE_COMPARE_MODE: number;
  62423. readonly COMPARE_REF_TO_TEXTURE: number;
  62424. readonly TEXTURE_WRAP_R: number;
  62425. readonly HALF_FLOAT: number;
  62426. readonly RGB8: number;
  62427. readonly RED_INTEGER: number;
  62428. readonly RG_INTEGER: number;
  62429. readonly RGB_INTEGER: number;
  62430. readonly RGBA_INTEGER: number;
  62431. readonly R8_SNORM: number;
  62432. readonly RG8_SNORM: number;
  62433. readonly RGB8_SNORM: number;
  62434. readonly RGBA8_SNORM: number;
  62435. readonly R8I: number;
  62436. readonly RG8I: number;
  62437. readonly RGB8I: number;
  62438. readonly RGBA8I: number;
  62439. readonly R8UI: number;
  62440. readonly RG8UI: number;
  62441. readonly RGB8UI: number;
  62442. readonly RGBA8UI: number;
  62443. readonly R16I: number;
  62444. readonly RG16I: number;
  62445. readonly RGB16I: number;
  62446. readonly RGBA16I: number;
  62447. readonly R16UI: number;
  62448. readonly RG16UI: number;
  62449. readonly RGB16UI: number;
  62450. readonly RGBA16UI: number;
  62451. readonly R32I: number;
  62452. readonly RG32I: number;
  62453. readonly RGB32I: number;
  62454. readonly RGBA32I: number;
  62455. readonly R32UI: number;
  62456. readonly RG32UI: number;
  62457. readonly RGB32UI: number;
  62458. readonly RGBA32UI: number;
  62459. readonly RGB10_A2UI: number;
  62460. readonly R11F_G11F_B10F: number;
  62461. readonly RGB9_E5: number;
  62462. readonly RGB10_A2: number;
  62463. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62464. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62465. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62466. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62467. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62468. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62469. 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;
  62470. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62471. readonly TRANSFORM_FEEDBACK: number;
  62472. readonly INTERLEAVED_ATTRIBS: number;
  62473. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62474. createTransformFeedback(): WebGLTransformFeedback;
  62475. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62476. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62477. beginTransformFeedback(primitiveMode: number): void;
  62478. endTransformFeedback(): void;
  62479. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62480. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62481. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62482. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62483. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62484. }
  62485. interface ImageBitmap {
  62486. readonly width: number;
  62487. readonly height: number;
  62488. close(): void;
  62489. }
  62490. interface WebGLQuery extends WebGLObject {
  62491. }
  62492. declare var WebGLQuery: {
  62493. prototype: WebGLQuery;
  62494. new(): WebGLQuery;
  62495. };
  62496. interface WebGLSampler extends WebGLObject {
  62497. }
  62498. declare var WebGLSampler: {
  62499. prototype: WebGLSampler;
  62500. new(): WebGLSampler;
  62501. };
  62502. interface WebGLSync extends WebGLObject {
  62503. }
  62504. declare var WebGLSync: {
  62505. prototype: WebGLSync;
  62506. new(): WebGLSync;
  62507. };
  62508. interface WebGLTransformFeedback extends WebGLObject {
  62509. }
  62510. declare var WebGLTransformFeedback: {
  62511. prototype: WebGLTransformFeedback;
  62512. new(): WebGLTransformFeedback;
  62513. };
  62514. interface WebGLVertexArrayObject extends WebGLObject {
  62515. }
  62516. declare var WebGLVertexArrayObject: {
  62517. prototype: WebGLVertexArrayObject;
  62518. new(): WebGLVertexArrayObject;
  62519. };
  62520. // Type definitions for WebVR API
  62521. // Project: https://w3c.github.io/webvr/
  62522. // Definitions by: six a <https://github.com/lostfictions>
  62523. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62524. interface VRDisplay extends EventTarget {
  62525. /**
  62526. * Dictionary of capabilities describing the VRDisplay.
  62527. */
  62528. readonly capabilities: VRDisplayCapabilities;
  62529. /**
  62530. * z-depth defining the far plane of the eye view frustum
  62531. * enables mapping of values in the render target depth
  62532. * attachment to scene coordinates. Initially set to 10000.0.
  62533. */
  62534. depthFar: number;
  62535. /**
  62536. * z-depth defining the near plane of the eye view frustum
  62537. * enables mapping of values in the render target depth
  62538. * attachment to scene coordinates. Initially set to 0.01.
  62539. */
  62540. depthNear: number;
  62541. /**
  62542. * An identifier for this distinct VRDisplay. Used as an
  62543. * association point in the Gamepad API.
  62544. */
  62545. readonly displayId: number;
  62546. /**
  62547. * A display name, a user-readable name identifying it.
  62548. */
  62549. readonly displayName: string;
  62550. readonly isConnected: boolean;
  62551. readonly isPresenting: boolean;
  62552. /**
  62553. * If this VRDisplay supports room-scale experiences, the optional
  62554. * stage attribute contains details on the room-scale parameters.
  62555. */
  62556. readonly stageParameters: VRStageParameters | null;
  62557. /**
  62558. * Passing the value returned by `requestAnimationFrame` to
  62559. * `cancelAnimationFrame` will unregister the callback.
  62560. * @param handle Define the hanle of the request to cancel
  62561. */
  62562. cancelAnimationFrame(handle: number): void;
  62563. /**
  62564. * Stops presenting to the VRDisplay.
  62565. * @returns a promise to know when it stopped
  62566. */
  62567. exitPresent(): Promise<void>;
  62568. /**
  62569. * Return the current VREyeParameters for the given eye.
  62570. * @param whichEye Define the eye we want the parameter for
  62571. * @returns the eye parameters
  62572. */
  62573. getEyeParameters(whichEye: string): VREyeParameters;
  62574. /**
  62575. * Populates the passed VRFrameData with the information required to render
  62576. * the current frame.
  62577. * @param frameData Define the data structure to populate
  62578. * @returns true if ok otherwise false
  62579. */
  62580. getFrameData(frameData: VRFrameData): boolean;
  62581. /**
  62582. * Get the layers currently being presented.
  62583. * @returns the list of VR layers
  62584. */
  62585. getLayers(): VRLayer[];
  62586. /**
  62587. * Return a VRPose containing the future predicted pose of the VRDisplay
  62588. * when the current frame will be presented. The value returned will not
  62589. * change until JavaScript has returned control to the browser.
  62590. *
  62591. * The VRPose will contain the position, orientation, velocity,
  62592. * and acceleration of each of these properties.
  62593. * @returns the pose object
  62594. */
  62595. getPose(): VRPose;
  62596. /**
  62597. * Return the current instantaneous pose of the VRDisplay, with no
  62598. * prediction applied.
  62599. * @returns the current instantaneous pose
  62600. */
  62601. getImmediatePose(): VRPose;
  62602. /**
  62603. * The callback passed to `requestAnimationFrame` will be called
  62604. * any time a new frame should be rendered. When the VRDisplay is
  62605. * presenting the callback will be called at the native refresh
  62606. * rate of the HMD. When not presenting this function acts
  62607. * identically to how window.requestAnimationFrame acts. Content should
  62608. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62609. * asynchronously from other displays and at differing refresh rates.
  62610. * @param callback Define the eaction to run next frame
  62611. * @returns the request handle it
  62612. */
  62613. requestAnimationFrame(callback: FrameRequestCallback): number;
  62614. /**
  62615. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62616. * Repeat calls while already presenting will update the VRLayers being displayed.
  62617. * @param layers Define the list of layer to present
  62618. * @returns a promise to know when the request has been fulfilled
  62619. */
  62620. requestPresent(layers: VRLayer[]): Promise<void>;
  62621. /**
  62622. * Reset the pose for this display, treating its current position and
  62623. * orientation as the "origin/zero" values. VRPose.position,
  62624. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62625. * updated when calling resetPose(). This should be called in only
  62626. * sitting-space experiences.
  62627. */
  62628. resetPose(): void;
  62629. /**
  62630. * The VRLayer provided to the VRDisplay will be captured and presented
  62631. * in the HMD. Calling this function has the same effect on the source
  62632. * canvas as any other operation that uses its source image, and canvases
  62633. * created without preserveDrawingBuffer set to true will be cleared.
  62634. * @param pose Define the pose to submit
  62635. */
  62636. submitFrame(pose?: VRPose): void;
  62637. }
  62638. declare var VRDisplay: {
  62639. prototype: VRDisplay;
  62640. new(): VRDisplay;
  62641. };
  62642. interface VRLayer {
  62643. leftBounds?: number[] | Float32Array | null;
  62644. rightBounds?: number[] | Float32Array | null;
  62645. source?: HTMLCanvasElement | null;
  62646. }
  62647. interface VRDisplayCapabilities {
  62648. readonly canPresent: boolean;
  62649. readonly hasExternalDisplay: boolean;
  62650. readonly hasOrientation: boolean;
  62651. readonly hasPosition: boolean;
  62652. readonly maxLayers: number;
  62653. }
  62654. interface VREyeParameters {
  62655. /** @deprecated */
  62656. readonly fieldOfView: VRFieldOfView;
  62657. readonly offset: Float32Array;
  62658. readonly renderHeight: number;
  62659. readonly renderWidth: number;
  62660. }
  62661. interface VRFieldOfView {
  62662. readonly downDegrees: number;
  62663. readonly leftDegrees: number;
  62664. readonly rightDegrees: number;
  62665. readonly upDegrees: number;
  62666. }
  62667. interface VRFrameData {
  62668. readonly leftProjectionMatrix: Float32Array;
  62669. readonly leftViewMatrix: Float32Array;
  62670. readonly pose: VRPose;
  62671. readonly rightProjectionMatrix: Float32Array;
  62672. readonly rightViewMatrix: Float32Array;
  62673. readonly timestamp: number;
  62674. }
  62675. interface VRPose {
  62676. readonly angularAcceleration: Float32Array | null;
  62677. readonly angularVelocity: Float32Array | null;
  62678. readonly linearAcceleration: Float32Array | null;
  62679. readonly linearVelocity: Float32Array | null;
  62680. readonly orientation: Float32Array | null;
  62681. readonly position: Float32Array | null;
  62682. readonly timestamp: number;
  62683. }
  62684. interface VRStageParameters {
  62685. sittingToStandingTransform?: Float32Array;
  62686. sizeX?: number;
  62687. sizeY?: number;
  62688. }
  62689. interface Navigator {
  62690. getVRDisplays(): Promise<VRDisplay[]>;
  62691. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62692. }
  62693. interface Window {
  62694. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62695. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62696. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62697. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62698. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62699. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62700. }
  62701. interface Gamepad {
  62702. readonly displayId: number;
  62703. }
  62704. type XRSessionMode =
  62705. | "inline"
  62706. | "immersive-vr"
  62707. | "immersive-ar";
  62708. type XRReferenceSpaceType =
  62709. | "viewer"
  62710. | "local"
  62711. | "local-floor"
  62712. | "bounded-floor"
  62713. | "unbounded";
  62714. type XREnvironmentBlendMode =
  62715. | "opaque"
  62716. | "additive"
  62717. | "alpha-blend";
  62718. type XRVisibilityState =
  62719. | "visible"
  62720. | "visible-blurred"
  62721. | "hidden";
  62722. type XRHandedness =
  62723. | "none"
  62724. | "left"
  62725. | "right";
  62726. type XRTargetRayMode =
  62727. | "gaze"
  62728. | "tracked-pointer"
  62729. | "screen";
  62730. type XREye =
  62731. | "none"
  62732. | "left"
  62733. | "right";
  62734. interface XRSpace extends EventTarget {
  62735. }
  62736. interface XRRenderState {
  62737. depthNear?: number;
  62738. depthFar?: number;
  62739. inlineVerticalFieldOfView?: number;
  62740. baseLayer?: XRWebGLLayer;
  62741. }
  62742. interface XRInputSource {
  62743. handedness: XRHandedness;
  62744. targetRayMode: XRTargetRayMode;
  62745. targetRaySpace: XRSpace;
  62746. gripSpace: XRSpace | undefined;
  62747. gamepad: Gamepad | undefined;
  62748. profiles: Array<string>;
  62749. }
  62750. interface XRSession {
  62751. addEventListener: Function;
  62752. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62753. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62754. requestAnimationFrame: Function;
  62755. end(): Promise<void>;
  62756. renderState: XRRenderState;
  62757. inputSources: Array<XRInputSource>;
  62758. }
  62759. interface XRReferenceSpace extends XRSpace {
  62760. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62761. onreset: any;
  62762. }
  62763. interface XRFrame {
  62764. session: XRSession;
  62765. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62766. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62767. }
  62768. interface XRViewerPose extends XRPose {
  62769. views: Array<XRView>;
  62770. }
  62771. interface XRPose {
  62772. transform: XRRigidTransform;
  62773. emulatedPosition: boolean;
  62774. }
  62775. declare var XRWebGLLayer: {
  62776. prototype: XRWebGLLayer;
  62777. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62778. };
  62779. interface XRWebGLLayer {
  62780. framebuffer: WebGLFramebuffer;
  62781. framebufferWidth: number;
  62782. framebufferHeight: number;
  62783. getViewport: Function;
  62784. }
  62785. interface XRRigidTransform {
  62786. position: DOMPointReadOnly;
  62787. orientation: DOMPointReadOnly;
  62788. matrix: Float32Array;
  62789. inverse: XRRigidTransform;
  62790. }
  62791. interface XRView {
  62792. eye: XREye;
  62793. projectionMatrix: Float32Array;
  62794. transform: XRRigidTransform;
  62795. }
  62796. interface XRInputSourceChangeEvent {
  62797. session: XRSession;
  62798. removed: Array<XRInputSource>;
  62799. added: Array<XRInputSource>;
  62800. }
  62801. declare module BABYLON.GUI {
  62802. /**
  62803. * Class used to specific a value and its associated unit
  62804. */
  62805. export class ValueAndUnit {
  62806. /** defines the unit to store */
  62807. unit: number;
  62808. /** defines a boolean indicating if the value can be negative */
  62809. negativeValueAllowed: boolean;
  62810. private _value;
  62811. private _originalUnit;
  62812. /**
  62813. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62814. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62815. */
  62816. ignoreAdaptiveScaling: boolean;
  62817. /**
  62818. * Creates a new ValueAndUnit
  62819. * @param value defines the value to store
  62820. * @param unit defines the unit to store
  62821. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62822. */
  62823. constructor(value: number,
  62824. /** defines the unit to store */
  62825. unit?: number,
  62826. /** defines a boolean indicating if the value can be negative */
  62827. negativeValueAllowed?: boolean);
  62828. /** Gets a boolean indicating if the value is a percentage */
  62829. readonly isPercentage: boolean;
  62830. /** Gets a boolean indicating if the value is store as pixel */
  62831. readonly isPixel: boolean;
  62832. /** Gets direct internal value */
  62833. readonly internalValue: number;
  62834. /**
  62835. * Gets value as pixel
  62836. * @param host defines the root host
  62837. * @param refValue defines the reference value for percentages
  62838. * @returns the value as pixel
  62839. */
  62840. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62841. /**
  62842. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62843. * @param value defines the value to store
  62844. * @param unit defines the unit to store
  62845. * @returns the current ValueAndUnit
  62846. */
  62847. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62848. /**
  62849. * Gets the value accordingly to its unit
  62850. * @param host defines the root host
  62851. * @returns the value
  62852. */
  62853. getValue(host: AdvancedDynamicTexture): number;
  62854. /**
  62855. * Gets a string representation of the value
  62856. * @param host defines the root host
  62857. * @param decimals defines an optional number of decimals to display
  62858. * @returns a string
  62859. */
  62860. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62861. /**
  62862. * Store a value parsed from a string
  62863. * @param source defines the source string
  62864. * @returns true if the value was successfully parsed
  62865. */
  62866. fromString(source: string | number): boolean;
  62867. private static _Regex;
  62868. private static _UNITMODE_PERCENTAGE;
  62869. private static _UNITMODE_PIXEL;
  62870. /** UNITMODE_PERCENTAGE */
  62871. static readonly UNITMODE_PERCENTAGE: number;
  62872. /** UNITMODE_PIXEL */
  62873. static readonly UNITMODE_PIXEL: number;
  62874. }
  62875. }
  62876. declare module BABYLON.GUI {
  62877. /**
  62878. * Define a style used by control to automatically setup properties based on a template.
  62879. * Only support font related properties so far
  62880. */
  62881. export class Style implements BABYLON.IDisposable {
  62882. private _fontFamily;
  62883. private _fontStyle;
  62884. private _fontWeight;
  62885. /** @hidden */
  62886. _host: AdvancedDynamicTexture;
  62887. /** @hidden */
  62888. _fontSize: ValueAndUnit;
  62889. /**
  62890. * BABYLON.Observable raised when the style values are changed
  62891. */
  62892. onChangedObservable: BABYLON.Observable<Style>;
  62893. /**
  62894. * Creates a new style object
  62895. * @param host defines the AdvancedDynamicTexture which hosts this style
  62896. */
  62897. constructor(host: AdvancedDynamicTexture);
  62898. /**
  62899. * Gets or sets the font size
  62900. */
  62901. fontSize: string | number;
  62902. /**
  62903. * Gets or sets the font family
  62904. */
  62905. fontFamily: string;
  62906. /**
  62907. * Gets or sets the font style
  62908. */
  62909. fontStyle: string;
  62910. /** Gets or sets font weight */
  62911. fontWeight: string;
  62912. /** Dispose all associated resources */
  62913. dispose(): void;
  62914. }
  62915. }
  62916. declare module BABYLON.GUI {
  62917. /**
  62918. * Class used to transport BABYLON.Vector2 information for pointer events
  62919. */
  62920. export class Vector2WithInfo extends BABYLON.Vector2 {
  62921. /** defines the current mouse button index */
  62922. buttonIndex: number;
  62923. /**
  62924. * Creates a new Vector2WithInfo
  62925. * @param source defines the vector2 data to transport
  62926. * @param buttonIndex defines the current mouse button index
  62927. */
  62928. constructor(source: BABYLON.Vector2,
  62929. /** defines the current mouse button index */
  62930. buttonIndex?: number);
  62931. }
  62932. /** Class used to provide 2D matrix features */
  62933. export class Matrix2D {
  62934. /** Gets the internal array of 6 floats used to store matrix data */
  62935. m: Float32Array;
  62936. /**
  62937. * Creates a new matrix
  62938. * @param m00 defines value for (0, 0)
  62939. * @param m01 defines value for (0, 1)
  62940. * @param m10 defines value for (1, 0)
  62941. * @param m11 defines value for (1, 1)
  62942. * @param m20 defines value for (2, 0)
  62943. * @param m21 defines value for (2, 1)
  62944. */
  62945. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  62946. /**
  62947. * Fills the matrix from direct values
  62948. * @param m00 defines value for (0, 0)
  62949. * @param m01 defines value for (0, 1)
  62950. * @param m10 defines value for (1, 0)
  62951. * @param m11 defines value for (1, 1)
  62952. * @param m20 defines value for (2, 0)
  62953. * @param m21 defines value for (2, 1)
  62954. * @returns the current modified matrix
  62955. */
  62956. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  62957. /**
  62958. * Gets matrix determinant
  62959. * @returns the determinant
  62960. */
  62961. determinant(): number;
  62962. /**
  62963. * Inverses the matrix and stores it in a target matrix
  62964. * @param result defines the target matrix
  62965. * @returns the current matrix
  62966. */
  62967. invertToRef(result: Matrix2D): Matrix2D;
  62968. /**
  62969. * Multiplies the current matrix with another one
  62970. * @param other defines the second operand
  62971. * @param result defines the target matrix
  62972. * @returns the current matrix
  62973. */
  62974. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  62975. /**
  62976. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  62977. * @param x defines the x coordinate to transform
  62978. * @param y defines the x coordinate to transform
  62979. * @param result defines the target vector2
  62980. * @returns the current matrix
  62981. */
  62982. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  62983. /**
  62984. * Creates an identity matrix
  62985. * @returns a new matrix
  62986. */
  62987. static Identity(): Matrix2D;
  62988. /**
  62989. * Creates a translation matrix and stores it in a target matrix
  62990. * @param x defines the x coordinate of the translation
  62991. * @param y defines the y coordinate of the translation
  62992. * @param result defines the target matrix
  62993. */
  62994. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  62995. /**
  62996. * Creates a scaling matrix and stores it in a target matrix
  62997. * @param x defines the x coordinate of the scaling
  62998. * @param y defines the y coordinate of the scaling
  62999. * @param result defines the target matrix
  63000. */
  63001. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63002. /**
  63003. * Creates a rotation matrix and stores it in a target matrix
  63004. * @param angle defines the rotation angle
  63005. * @param result defines the target matrix
  63006. */
  63007. static RotationToRef(angle: number, result: Matrix2D): void;
  63008. private static _TempPreTranslationMatrix;
  63009. private static _TempPostTranslationMatrix;
  63010. private static _TempRotationMatrix;
  63011. private static _TempScalingMatrix;
  63012. private static _TempCompose0;
  63013. private static _TempCompose1;
  63014. private static _TempCompose2;
  63015. /**
  63016. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63017. * @param tx defines the x coordinate of the translation
  63018. * @param ty defines the y coordinate of the translation
  63019. * @param angle defines the rotation angle
  63020. * @param scaleX defines the x coordinate of the scaling
  63021. * @param scaleY defines the y coordinate of the scaling
  63022. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63023. * @param result defines the target matrix
  63024. */
  63025. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63026. }
  63027. }
  63028. declare module BABYLON.GUI {
  63029. /**
  63030. * Class used to store 2D control sizes
  63031. */
  63032. export class Measure {
  63033. /** defines left coordinate */
  63034. left: number;
  63035. /** defines top coordinate */
  63036. top: number;
  63037. /** defines width dimension */
  63038. width: number;
  63039. /** defines height dimension */
  63040. height: number;
  63041. /**
  63042. * Creates a new measure
  63043. * @param left defines left coordinate
  63044. * @param top defines top coordinate
  63045. * @param width defines width dimension
  63046. * @param height defines height dimension
  63047. */
  63048. constructor(
  63049. /** defines left coordinate */
  63050. left: number,
  63051. /** defines top coordinate */
  63052. top: number,
  63053. /** defines width dimension */
  63054. width: number,
  63055. /** defines height dimension */
  63056. height: number);
  63057. /**
  63058. * Copy from another measure
  63059. * @param other defines the other measure to copy from
  63060. */
  63061. copyFrom(other: Measure): void;
  63062. /**
  63063. * Copy from a group of 4 floats
  63064. * @param left defines left coordinate
  63065. * @param top defines top coordinate
  63066. * @param width defines width dimension
  63067. * @param height defines height dimension
  63068. */
  63069. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63070. /**
  63071. * Computes the axis aligned bounding box measure for two given measures
  63072. * @param a Input measure
  63073. * @param b Input measure
  63074. * @param result the resulting bounding measure
  63075. */
  63076. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63077. /**
  63078. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63079. * @param transform the matrix to transform the measure before computing the AABB
  63080. * @param result the resulting AABB
  63081. */
  63082. transformToRef(transform: Matrix2D, result: Measure): void;
  63083. /**
  63084. * Check equality between this measure and another one
  63085. * @param other defines the other measures
  63086. * @returns true if both measures are equals
  63087. */
  63088. isEqualsTo(other: Measure): boolean;
  63089. /**
  63090. * Creates an empty measure
  63091. * @returns a new measure
  63092. */
  63093. static Empty(): Measure;
  63094. }
  63095. }
  63096. declare module BABYLON.GUI {
  63097. /**
  63098. * Interface used to define a control that can receive focus
  63099. */
  63100. export interface IFocusableControl {
  63101. /**
  63102. * Function called when the control receives the focus
  63103. */
  63104. onFocus(): void;
  63105. /**
  63106. * Function called when the control loses the focus
  63107. */
  63108. onBlur(): void;
  63109. /**
  63110. * Function called to let the control handle keyboard events
  63111. * @param evt defines the current keyboard event
  63112. */
  63113. processKeyboard(evt: KeyboardEvent): void;
  63114. /**
  63115. * Function called to get the list of controls that should not steal the focus from this control
  63116. * @returns an array of controls
  63117. */
  63118. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63119. }
  63120. /**
  63121. * Class used to create texture to support 2D GUI elements
  63122. * @see http://doc.babylonjs.com/how_to/gui
  63123. */
  63124. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63125. private _isDirty;
  63126. private _renderObserver;
  63127. private _resizeObserver;
  63128. private _preKeyboardObserver;
  63129. private _pointerMoveObserver;
  63130. private _pointerObserver;
  63131. private _canvasPointerOutObserver;
  63132. private _background;
  63133. /** @hidden */
  63134. _rootContainer: Container;
  63135. /** @hidden */
  63136. _lastPickedControl: Control;
  63137. /** @hidden */
  63138. _lastControlOver: {
  63139. [pointerId: number]: Control;
  63140. };
  63141. /** @hidden */
  63142. _lastControlDown: {
  63143. [pointerId: number]: Control;
  63144. };
  63145. /** @hidden */
  63146. _capturingControl: {
  63147. [pointerId: number]: Control;
  63148. };
  63149. /** @hidden */
  63150. _shouldBlockPointer: boolean;
  63151. /** @hidden */
  63152. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63153. /** @hidden */
  63154. _linkedControls: Control[];
  63155. private _isFullscreen;
  63156. private _fullscreenViewport;
  63157. private _idealWidth;
  63158. private _idealHeight;
  63159. private _useSmallestIdeal;
  63160. private _renderAtIdealSize;
  63161. private _focusedControl;
  63162. private _blockNextFocusCheck;
  63163. private _renderScale;
  63164. private _rootCanvas;
  63165. private _cursorChanged;
  63166. /**
  63167. * Define type to string to ensure compatibility across browsers
  63168. * Safari doesn't support DataTransfer constructor
  63169. */
  63170. private _clipboardData;
  63171. /**
  63172. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63173. */
  63174. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63175. /**
  63176. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63177. */
  63178. onControlPickedObservable: BABYLON.Observable<Control>;
  63179. /**
  63180. * BABYLON.Observable event triggered before layout is evaluated
  63181. */
  63182. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63183. /**
  63184. * BABYLON.Observable event triggered after the layout was evaluated
  63185. */
  63186. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63187. /**
  63188. * BABYLON.Observable event triggered before the texture is rendered
  63189. */
  63190. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63191. /**
  63192. * BABYLON.Observable event triggered after the texture was rendered
  63193. */
  63194. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63195. /**
  63196. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63197. */
  63198. premulAlpha: boolean;
  63199. /**
  63200. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63201. * Useful when you want more antialiasing
  63202. */
  63203. renderScale: number;
  63204. /** Gets or sets the background color */
  63205. background: string;
  63206. /**
  63207. * Gets or sets the ideal width used to design controls.
  63208. * The GUI will then rescale everything accordingly
  63209. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63210. */
  63211. idealWidth: number;
  63212. /**
  63213. * Gets or sets the ideal height used to design controls.
  63214. * The GUI will then rescale everything accordingly
  63215. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63216. */
  63217. idealHeight: number;
  63218. /**
  63219. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63220. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63221. */
  63222. useSmallestIdeal: boolean;
  63223. /**
  63224. * Gets or sets a boolean indicating if adaptive scaling must be used
  63225. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63226. */
  63227. renderAtIdealSize: boolean;
  63228. /**
  63229. * Gets the underlying layer used to render the texture when in fullscreen mode
  63230. */
  63231. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63232. /**
  63233. * Gets the root container control
  63234. */
  63235. readonly rootContainer: Container;
  63236. /**
  63237. * Returns an array containing the root container.
  63238. * This is mostly used to let the Inspector introspects the ADT
  63239. * @returns an array containing the rootContainer
  63240. */
  63241. getChildren(): Array<Container>;
  63242. /**
  63243. * Will return all controls that are inside this texture
  63244. * @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
  63245. * @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
  63246. * @return all child controls
  63247. */
  63248. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63249. /**
  63250. * Gets or sets the current focused control
  63251. */
  63252. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63253. /**
  63254. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63255. */
  63256. isForeground: boolean;
  63257. /**
  63258. * Gets or set information about clipboardData
  63259. */
  63260. clipboardData: string;
  63261. /**
  63262. * Creates a new AdvancedDynamicTexture
  63263. * @param name defines the name of the texture
  63264. * @param width defines the width of the texture
  63265. * @param height defines the height of the texture
  63266. * @param scene defines the hosting scene
  63267. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63268. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63269. */
  63270. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63271. /**
  63272. * Get the current class name of the texture useful for serialization or dynamic coding.
  63273. * @returns "AdvancedDynamicTexture"
  63274. */
  63275. getClassName(): string;
  63276. /**
  63277. * Function used to execute a function on all controls
  63278. * @param func defines the function to execute
  63279. * @param container defines the container where controls belong. If null the root container will be used
  63280. */
  63281. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63282. private _useInvalidateRectOptimization;
  63283. /**
  63284. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63285. */
  63286. useInvalidateRectOptimization: boolean;
  63287. private _invalidatedRectangle;
  63288. /**
  63289. * Invalidates a rectangle area on the gui texture
  63290. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63291. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63292. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63293. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63294. */
  63295. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63296. /**
  63297. * Marks the texture as dirty forcing a complete update
  63298. */
  63299. markAsDirty(): void;
  63300. /**
  63301. * Helper function used to create a new style
  63302. * @returns a new style
  63303. * @see http://doc.babylonjs.com/how_to/gui#styles
  63304. */
  63305. createStyle(): Style;
  63306. /**
  63307. * Adds a new control to the root container
  63308. * @param control defines the control to add
  63309. * @returns the current texture
  63310. */
  63311. addControl(control: Control): AdvancedDynamicTexture;
  63312. /**
  63313. * Removes a control from the root container
  63314. * @param control defines the control to remove
  63315. * @returns the current texture
  63316. */
  63317. removeControl(control: Control): AdvancedDynamicTexture;
  63318. /**
  63319. * Release all resources
  63320. */
  63321. dispose(): void;
  63322. private _onResize;
  63323. /** @hidden */
  63324. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63325. /**
  63326. * Get screen coordinates for a vector3
  63327. * @param position defines the position to project
  63328. * @param worldMatrix defines the world matrix to use
  63329. * @returns the projected position
  63330. */
  63331. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63332. private _checkUpdate;
  63333. private _clearMeasure;
  63334. private _render;
  63335. /** @hidden */
  63336. _changeCursor(cursor: string): void;
  63337. /** @hidden */
  63338. _registerLastControlDown(control: Control, pointerId: number): void;
  63339. private _doPicking;
  63340. /** @hidden */
  63341. _cleanControlAfterRemovalFromList(list: {
  63342. [pointerId: number]: Control;
  63343. }, control: Control): void;
  63344. /** @hidden */
  63345. _cleanControlAfterRemoval(control: Control): void;
  63346. /** Attach to all scene events required to support pointer events */
  63347. attach(): void;
  63348. /** @hidden */
  63349. private onClipboardCopy;
  63350. /** @hidden */
  63351. private onClipboardCut;
  63352. /** @hidden */
  63353. private onClipboardPaste;
  63354. /**
  63355. * Register the clipboard Events onto the canvas
  63356. */
  63357. registerClipboardEvents(): void;
  63358. /**
  63359. * Unregister the clipboard Events from the canvas
  63360. */
  63361. unRegisterClipboardEvents(): void;
  63362. /**
  63363. * Connect the texture to a hosting mesh to enable interactions
  63364. * @param mesh defines the mesh to attach to
  63365. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63366. */
  63367. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63368. /**
  63369. * Move the focus to a specific control
  63370. * @param control defines the control which will receive the focus
  63371. */
  63372. moveFocusToControl(control: IFocusableControl): void;
  63373. private _manageFocus;
  63374. private _attachToOnPointerOut;
  63375. /**
  63376. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63377. * @param mesh defines the mesh which will receive the texture
  63378. * @param width defines the texture width (1024 by default)
  63379. * @param height defines the texture height (1024 by default)
  63380. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63381. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63382. * @returns a new AdvancedDynamicTexture
  63383. */
  63384. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63385. /**
  63386. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63387. * In this mode the texture will rely on a layer for its rendering.
  63388. * This allows it to be treated like any other layer.
  63389. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63390. * LayerMask is set through advancedTexture.layer.layerMask
  63391. * @param name defines name for the texture
  63392. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63393. * @param scene defines the hsoting scene
  63394. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63395. * @returns a new AdvancedDynamicTexture
  63396. */
  63397. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63398. }
  63399. }
  63400. declare module BABYLON.GUI {
  63401. /**
  63402. * Root class used for all 2D controls
  63403. * @see http://doc.babylonjs.com/how_to/gui#controls
  63404. */
  63405. export class Control {
  63406. /** defines the name of the control */
  63407. name?: string | undefined;
  63408. /**
  63409. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63410. */
  63411. static AllowAlphaInheritance: boolean;
  63412. private _alpha;
  63413. private _alphaSet;
  63414. private _zIndex;
  63415. /** @hidden */
  63416. _host: AdvancedDynamicTexture;
  63417. /** Gets or sets the control parent */
  63418. parent: BABYLON.Nullable<Container>;
  63419. /** @hidden */
  63420. _currentMeasure: Measure;
  63421. private _fontFamily;
  63422. private _fontStyle;
  63423. private _fontWeight;
  63424. private _fontSize;
  63425. private _font;
  63426. /** @hidden */
  63427. _width: ValueAndUnit;
  63428. /** @hidden */
  63429. _height: ValueAndUnit;
  63430. /** @hidden */
  63431. protected _fontOffset: {
  63432. ascent: number;
  63433. height: number;
  63434. descent: number;
  63435. };
  63436. private _color;
  63437. private _style;
  63438. private _styleObserver;
  63439. /** @hidden */
  63440. protected _horizontalAlignment: number;
  63441. /** @hidden */
  63442. protected _verticalAlignment: number;
  63443. /** @hidden */
  63444. protected _isDirty: boolean;
  63445. /** @hidden */
  63446. protected _wasDirty: boolean;
  63447. /** @hidden */
  63448. _tempParentMeasure: Measure;
  63449. /** @hidden */
  63450. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63451. /** @hidden */
  63452. protected _cachedParentMeasure: Measure;
  63453. private _paddingLeft;
  63454. private _paddingRight;
  63455. private _paddingTop;
  63456. private _paddingBottom;
  63457. /** @hidden */
  63458. _left: ValueAndUnit;
  63459. /** @hidden */
  63460. _top: ValueAndUnit;
  63461. private _scaleX;
  63462. private _scaleY;
  63463. private _rotation;
  63464. private _transformCenterX;
  63465. private _transformCenterY;
  63466. /** @hidden */
  63467. _transformMatrix: Matrix2D;
  63468. /** @hidden */
  63469. protected _invertTransformMatrix: Matrix2D;
  63470. /** @hidden */
  63471. protected _transformedPosition: BABYLON.Vector2;
  63472. private _isMatrixDirty;
  63473. private _cachedOffsetX;
  63474. private _cachedOffsetY;
  63475. private _isVisible;
  63476. private _isHighlighted;
  63477. /** @hidden */
  63478. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63479. private _fontSet;
  63480. private _dummyVector2;
  63481. private _downCount;
  63482. private _enterCount;
  63483. private _doNotRender;
  63484. private _downPointerIds;
  63485. protected _isEnabled: boolean;
  63486. protected _disabledColor: string;
  63487. /** @hidden */
  63488. protected _rebuildLayout: boolean;
  63489. /** @hidden */
  63490. _isClipped: boolean;
  63491. /** @hidden */
  63492. _tag: any;
  63493. /**
  63494. * 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
  63495. */
  63496. uniqueId: number;
  63497. /**
  63498. * Gets or sets an object used to store user defined information for the node
  63499. */
  63500. metadata: any;
  63501. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63502. isHitTestVisible: boolean;
  63503. /** Gets or sets a boolean indicating if the control can block pointer events */
  63504. isPointerBlocker: boolean;
  63505. /** Gets or sets a boolean indicating if the control can be focusable */
  63506. isFocusInvisible: boolean;
  63507. /**
  63508. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63509. * 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
  63510. */
  63511. clipChildren: boolean;
  63512. /**
  63513. * Gets or sets a boolean indicating that control content must be clipped
  63514. * 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
  63515. */
  63516. clipContent: boolean;
  63517. /**
  63518. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63519. */
  63520. useBitmapCache: boolean;
  63521. private _cacheData;
  63522. private _shadowOffsetX;
  63523. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63524. shadowOffsetX: number;
  63525. private _shadowOffsetY;
  63526. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63527. shadowOffsetY: number;
  63528. private _shadowBlur;
  63529. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63530. shadowBlur: number;
  63531. private _shadowColor;
  63532. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63533. shadowColor: string;
  63534. /** Gets or sets the cursor to use when the control is hovered */
  63535. hoverCursor: string;
  63536. /** @hidden */
  63537. protected _linkOffsetX: ValueAndUnit;
  63538. /** @hidden */
  63539. protected _linkOffsetY: ValueAndUnit;
  63540. /** Gets the control type name */
  63541. readonly typeName: string;
  63542. /**
  63543. * Get the current class name of the control.
  63544. * @returns current class name
  63545. */
  63546. getClassName(): string;
  63547. /**
  63548. * An event triggered when the pointer move over the control.
  63549. */
  63550. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63551. /**
  63552. * An event triggered when the pointer move out of the control.
  63553. */
  63554. onPointerOutObservable: BABYLON.Observable<Control>;
  63555. /**
  63556. * An event triggered when the pointer taps the control
  63557. */
  63558. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63559. /**
  63560. * An event triggered when pointer up
  63561. */
  63562. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63563. /**
  63564. * An event triggered when a control is clicked on
  63565. */
  63566. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63567. /**
  63568. * An event triggered when pointer enters the control
  63569. */
  63570. onPointerEnterObservable: BABYLON.Observable<Control>;
  63571. /**
  63572. * An event triggered when the control is marked as dirty
  63573. */
  63574. onDirtyObservable: BABYLON.Observable<Control>;
  63575. /**
  63576. * An event triggered before drawing the control
  63577. */
  63578. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63579. /**
  63580. * An event triggered after the control was drawn
  63581. */
  63582. onAfterDrawObservable: BABYLON.Observable<Control>;
  63583. /**
  63584. * Get the hosting AdvancedDynamicTexture
  63585. */
  63586. readonly host: AdvancedDynamicTexture;
  63587. /** Gets or set information about font offsets (used to render and align text) */
  63588. fontOffset: {
  63589. ascent: number;
  63590. height: number;
  63591. descent: number;
  63592. };
  63593. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63594. alpha: number;
  63595. /**
  63596. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63597. */
  63598. isHighlighted: boolean;
  63599. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63600. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63601. */
  63602. scaleX: number;
  63603. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63604. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63605. */
  63606. scaleY: number;
  63607. /** Gets or sets the rotation angle (0 by default)
  63608. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63609. */
  63610. rotation: number;
  63611. /** Gets or sets the transformation center on Y axis (0 by default)
  63612. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63613. */
  63614. transformCenterY: number;
  63615. /** Gets or sets the transformation center on X axis (0 by default)
  63616. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63617. */
  63618. transformCenterX: number;
  63619. /**
  63620. * Gets or sets the horizontal alignment
  63621. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63622. */
  63623. horizontalAlignment: number;
  63624. /**
  63625. * Gets or sets the vertical alignment
  63626. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63627. */
  63628. verticalAlignment: number;
  63629. /**
  63630. * Gets or sets control width
  63631. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63632. */
  63633. width: string | number;
  63634. /**
  63635. * Gets or sets the control width in pixel
  63636. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63637. */
  63638. widthInPixels: number;
  63639. /**
  63640. * Gets or sets control height
  63641. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63642. */
  63643. height: string | number;
  63644. /**
  63645. * Gets or sets control height in pixel
  63646. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63647. */
  63648. heightInPixels: number;
  63649. /** Gets or set font family */
  63650. fontFamily: string;
  63651. /** Gets or sets font style */
  63652. fontStyle: string;
  63653. /** Gets or sets font weight */
  63654. fontWeight: string;
  63655. /**
  63656. * Gets or sets style
  63657. * @see http://doc.babylonjs.com/how_to/gui#styles
  63658. */
  63659. style: BABYLON.Nullable<Style>;
  63660. /** @hidden */
  63661. readonly _isFontSizeInPercentage: boolean;
  63662. /** Gets or sets font size in pixels */
  63663. fontSizeInPixels: number;
  63664. /** Gets or sets font size */
  63665. fontSize: string | number;
  63666. /** Gets or sets foreground color */
  63667. color: string;
  63668. /** Gets or sets z index which is used to reorder controls on the z axis */
  63669. zIndex: number;
  63670. /** Gets or sets a boolean indicating if the control can be rendered */
  63671. notRenderable: boolean;
  63672. /** Gets or sets a boolean indicating if the control is visible */
  63673. isVisible: boolean;
  63674. /** Gets a boolean indicating that the control needs to update its rendering */
  63675. readonly isDirty: boolean;
  63676. /**
  63677. * Gets the current linked mesh (or null if none)
  63678. */
  63679. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63680. /**
  63681. * Gets or sets a value indicating the padding to use on the left of the control
  63682. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63683. */
  63684. paddingLeft: string | number;
  63685. /**
  63686. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63687. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63688. */
  63689. paddingLeftInPixels: number;
  63690. /**
  63691. * Gets or sets a value indicating the padding to use on the right of the control
  63692. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63693. */
  63694. paddingRight: string | number;
  63695. /**
  63696. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63697. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63698. */
  63699. paddingRightInPixels: number;
  63700. /**
  63701. * Gets or sets a value indicating the padding to use on the top of the control
  63702. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63703. */
  63704. paddingTop: string | number;
  63705. /**
  63706. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63707. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63708. */
  63709. paddingTopInPixels: number;
  63710. /**
  63711. * Gets or sets a value indicating the padding to use on the bottom of the control
  63712. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63713. */
  63714. paddingBottom: string | number;
  63715. /**
  63716. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63717. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63718. */
  63719. paddingBottomInPixels: number;
  63720. /**
  63721. * Gets or sets a value indicating the left coordinate of the control
  63722. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63723. */
  63724. left: string | number;
  63725. /**
  63726. * Gets or sets a value indicating the left coordinate in pixels of the control
  63727. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63728. */
  63729. leftInPixels: number;
  63730. /**
  63731. * Gets or sets a value indicating the top coordinate of the control
  63732. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63733. */
  63734. top: string | number;
  63735. /**
  63736. * Gets or sets a value indicating the top coordinate in pixels of the control
  63737. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63738. */
  63739. topInPixels: number;
  63740. /**
  63741. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63742. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63743. */
  63744. linkOffsetX: string | number;
  63745. /**
  63746. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63747. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63748. */
  63749. linkOffsetXInPixels: number;
  63750. /**
  63751. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63752. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63753. */
  63754. linkOffsetY: string | number;
  63755. /**
  63756. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63757. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63758. */
  63759. linkOffsetYInPixels: number;
  63760. /** Gets the center coordinate on X axis */
  63761. readonly centerX: number;
  63762. /** Gets the center coordinate on Y axis */
  63763. readonly centerY: number;
  63764. /** Gets or sets if control is Enabled*/
  63765. isEnabled: boolean;
  63766. /** Gets or sets background color of control if it's disabled*/
  63767. disabledColor: string;
  63768. /**
  63769. * Creates a new control
  63770. * @param name defines the name of the control
  63771. */
  63772. constructor(
  63773. /** defines the name of the control */
  63774. name?: string | undefined);
  63775. /** @hidden */
  63776. protected _getTypeName(): string;
  63777. /**
  63778. * Gets the first ascendant in the hierarchy of the given type
  63779. * @param className defines the required type
  63780. * @returns the ascendant or null if not found
  63781. */
  63782. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63783. /** @hidden */
  63784. _resetFontCache(): void;
  63785. /**
  63786. * Determines if a container is an ascendant of the current control
  63787. * @param container defines the container to look for
  63788. * @returns true if the container is one of the ascendant of the control
  63789. */
  63790. isAscendant(container: Control): boolean;
  63791. /**
  63792. * Gets coordinates in local control space
  63793. * @param globalCoordinates defines the coordinates to transform
  63794. * @returns the new coordinates in local space
  63795. */
  63796. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63797. /**
  63798. * Gets coordinates in local control space
  63799. * @param globalCoordinates defines the coordinates to transform
  63800. * @param result defines the target vector2 where to store the result
  63801. * @returns the current control
  63802. */
  63803. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63804. /**
  63805. * Gets coordinates in parent local control space
  63806. * @param globalCoordinates defines the coordinates to transform
  63807. * @returns the new coordinates in parent local space
  63808. */
  63809. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63810. /**
  63811. * Move the current control to a vector3 position projected onto the screen.
  63812. * @param position defines the target position
  63813. * @param scene defines the hosting scene
  63814. */
  63815. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63816. /** @hidden */
  63817. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63818. /**
  63819. * Will return all controls that have this control as ascendant
  63820. * @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
  63821. * @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
  63822. * @return all child controls
  63823. */
  63824. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63825. /**
  63826. * Link current control with a target mesh
  63827. * @param mesh defines the mesh to link with
  63828. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63829. */
  63830. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63831. /** @hidden */
  63832. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63833. /** @hidden */
  63834. _offsetLeft(offset: number): void;
  63835. /** @hidden */
  63836. _offsetTop(offset: number): void;
  63837. /** @hidden */
  63838. _markMatrixAsDirty(): void;
  63839. /** @hidden */
  63840. _flagDescendantsAsMatrixDirty(): void;
  63841. /** @hidden */
  63842. _intersectsRect(rect: Measure): boolean;
  63843. /** @hidden */
  63844. protected invalidateRect(): void;
  63845. /** @hidden */
  63846. _markAsDirty(force?: boolean): void;
  63847. /** @hidden */
  63848. _markAllAsDirty(): void;
  63849. /** @hidden */
  63850. _link(host: AdvancedDynamicTexture): void;
  63851. /** @hidden */
  63852. protected _transform(context?: CanvasRenderingContext2D): void;
  63853. /** @hidden */
  63854. _renderHighlight(context: CanvasRenderingContext2D): void;
  63855. /** @hidden */
  63856. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63857. /** @hidden */
  63858. protected _applyStates(context: CanvasRenderingContext2D): void;
  63859. /** @hidden */
  63860. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63861. /** @hidden */
  63862. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63863. protected _evaluateClippingState(parentMeasure: Measure): void;
  63864. /** @hidden */
  63865. _measure(): void;
  63866. /** @hidden */
  63867. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63868. /** @hidden */
  63869. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63870. /** @hidden */
  63871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63872. /** @hidden */
  63873. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63874. private static _ClipMeasure;
  63875. private _tmpMeasureA;
  63876. private _clip;
  63877. /** @hidden */
  63878. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63879. /** @hidden */
  63880. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63881. /**
  63882. * Tests if a given coordinates belong to the current control
  63883. * @param x defines x coordinate to test
  63884. * @param y defines y coordinate to test
  63885. * @returns true if the coordinates are inside the control
  63886. */
  63887. contains(x: number, y: number): boolean;
  63888. /** @hidden */
  63889. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63890. /** @hidden */
  63891. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63892. /** @hidden */
  63893. _onPointerEnter(target: Control): boolean;
  63894. /** @hidden */
  63895. _onPointerOut(target: Control, force?: boolean): void;
  63896. /** @hidden */
  63897. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63898. /** @hidden */
  63899. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63900. /** @hidden */
  63901. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63902. /** @hidden */
  63903. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63904. private _prepareFont;
  63905. /** Releases associated resources */
  63906. dispose(): void;
  63907. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63908. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63909. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63910. private static _VERTICAL_ALIGNMENT_TOP;
  63911. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63912. private static _VERTICAL_ALIGNMENT_CENTER;
  63913. /** HORIZONTAL_ALIGNMENT_LEFT */
  63914. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63915. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63916. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63917. /** HORIZONTAL_ALIGNMENT_CENTER */
  63918. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63919. /** VERTICAL_ALIGNMENT_TOP */
  63920. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63921. /** VERTICAL_ALIGNMENT_BOTTOM */
  63922. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63923. /** VERTICAL_ALIGNMENT_CENTER */
  63924. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63925. private static _FontHeightSizes;
  63926. /** @hidden */
  63927. static _GetFontOffset(font: string): {
  63928. ascent: number;
  63929. height: number;
  63930. descent: number;
  63931. };
  63932. /**
  63933. * Creates a stack panel that can be used to render headers
  63934. * @param control defines the control to associate with the header
  63935. * @param text defines the text of the header
  63936. * @param size defines the size of the header
  63937. * @param options defines options used to configure the header
  63938. * @returns a new StackPanel
  63939. * @ignore
  63940. * @hidden
  63941. */
  63942. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63943. isHorizontal: boolean;
  63944. controlFirst: boolean;
  63945. }) => any;
  63946. /** @hidden */
  63947. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63948. }
  63949. }
  63950. declare module BABYLON.GUI {
  63951. /**
  63952. * Root class for 2D containers
  63953. * @see http://doc.babylonjs.com/how_to/gui#containers
  63954. */
  63955. export class Container extends Control {
  63956. name?: string | undefined;
  63957. /** @hidden */
  63958. protected _children: Control[];
  63959. /** @hidden */
  63960. protected _measureForChildren: Measure;
  63961. /** @hidden */
  63962. protected _background: string;
  63963. /** @hidden */
  63964. protected _adaptWidthToChildren: boolean;
  63965. /** @hidden */
  63966. protected _adaptHeightToChildren: boolean;
  63967. /**
  63968. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63969. */
  63970. logLayoutCycleErrors: boolean;
  63971. /**
  63972. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63973. */
  63974. maxLayoutCycle: number;
  63975. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63976. adaptHeightToChildren: boolean;
  63977. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63978. adaptWidthToChildren: boolean;
  63979. /** Gets or sets background color */
  63980. background: string;
  63981. /** Gets the list of children */
  63982. readonly children: Control[];
  63983. /**
  63984. * Creates a new Container
  63985. * @param name defines the name of the container
  63986. */
  63987. constructor(name?: string | undefined);
  63988. protected _getTypeName(): string;
  63989. _flagDescendantsAsMatrixDirty(): void;
  63990. /**
  63991. * Gets a child using its name
  63992. * @param name defines the child name to look for
  63993. * @returns the child control if found
  63994. */
  63995. getChildByName(name: string): BABYLON.Nullable<Control>;
  63996. /**
  63997. * Gets a child using its type and its name
  63998. * @param name defines the child name to look for
  63999. * @param type defines the child type to look for
  64000. * @returns the child control if found
  64001. */
  64002. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64003. /**
  64004. * Search for a specific control in children
  64005. * @param control defines the control to look for
  64006. * @returns true if the control is in child list
  64007. */
  64008. containsControl(control: Control): boolean;
  64009. /**
  64010. * Adds a new control to the current container
  64011. * @param control defines the control to add
  64012. * @returns the current container
  64013. */
  64014. addControl(control: BABYLON.Nullable<Control>): Container;
  64015. /**
  64016. * Removes all controls from the current container
  64017. * @returns the current container
  64018. */
  64019. clearControls(): Container;
  64020. /**
  64021. * Removes a control from the current container
  64022. * @param control defines the control to remove
  64023. * @returns the current container
  64024. */
  64025. removeControl(control: Control): Container;
  64026. /** @hidden */
  64027. _reOrderControl(control: Control): void;
  64028. /** @hidden */
  64029. _offsetLeft(offset: number): void;
  64030. /** @hidden */
  64031. _offsetTop(offset: number): void;
  64032. /** @hidden */
  64033. _markAllAsDirty(): void;
  64034. /** @hidden */
  64035. protected _localDraw(context: CanvasRenderingContext2D): void;
  64036. /** @hidden */
  64037. _link(host: AdvancedDynamicTexture): void;
  64038. /** @hidden */
  64039. protected _beforeLayout(): void;
  64040. /** @hidden */
  64041. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64042. /** @hidden */
  64043. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64044. protected _postMeasure(): void;
  64045. /** @hidden */
  64046. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64047. /** @hidden */
  64048. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64049. /** @hidden */
  64050. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64051. /** @hidden */
  64052. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64053. /** Releases associated resources */
  64054. dispose(): void;
  64055. }
  64056. }
  64057. declare module BABYLON.GUI {
  64058. /** Class used to create rectangle container */
  64059. export class Rectangle extends Container {
  64060. name?: string | undefined;
  64061. private _thickness;
  64062. private _cornerRadius;
  64063. /** Gets or sets border thickness */
  64064. thickness: number;
  64065. /** Gets or sets the corner radius angle */
  64066. cornerRadius: number;
  64067. /**
  64068. * Creates a new Rectangle
  64069. * @param name defines the control name
  64070. */
  64071. constructor(name?: string | undefined);
  64072. protected _getTypeName(): string;
  64073. protected _localDraw(context: CanvasRenderingContext2D): void;
  64074. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64075. private _drawRoundedRect;
  64076. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64077. }
  64078. }
  64079. declare module BABYLON.GUI {
  64080. /**
  64081. * Enum that determines the text-wrapping mode to use.
  64082. */
  64083. export enum TextWrapping {
  64084. /**
  64085. * Clip the text when it's larger than Control.width; this is the default mode.
  64086. */
  64087. Clip = 0,
  64088. /**
  64089. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64090. */
  64091. WordWrap = 1,
  64092. /**
  64093. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64094. */
  64095. Ellipsis = 2
  64096. }
  64097. /**
  64098. * Class used to create text block control
  64099. */
  64100. export class TextBlock extends Control {
  64101. /**
  64102. * Defines the name of the control
  64103. */
  64104. name?: string | undefined;
  64105. private _text;
  64106. private _textWrapping;
  64107. private _textHorizontalAlignment;
  64108. private _textVerticalAlignment;
  64109. private _lines;
  64110. private _resizeToFit;
  64111. private _lineSpacing;
  64112. private _outlineWidth;
  64113. private _outlineColor;
  64114. /**
  64115. * An event triggered after the text is changed
  64116. */
  64117. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64118. /**
  64119. * An event triggered after the text was broken up into lines
  64120. */
  64121. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64122. /**
  64123. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64124. */
  64125. readonly lines: any[];
  64126. /**
  64127. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64128. */
  64129. /**
  64130. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64131. */
  64132. resizeToFit: boolean;
  64133. /**
  64134. * Gets or sets a boolean indicating if text must be wrapped
  64135. */
  64136. /**
  64137. * Gets or sets a boolean indicating if text must be wrapped
  64138. */
  64139. textWrapping: TextWrapping | boolean;
  64140. /**
  64141. * Gets or sets text to display
  64142. */
  64143. /**
  64144. * Gets or sets text to display
  64145. */
  64146. text: string;
  64147. /**
  64148. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64149. */
  64150. /**
  64151. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64152. */
  64153. textHorizontalAlignment: number;
  64154. /**
  64155. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64156. */
  64157. /**
  64158. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64159. */
  64160. textVerticalAlignment: number;
  64161. /**
  64162. * Gets or sets line spacing value
  64163. */
  64164. /**
  64165. * Gets or sets line spacing value
  64166. */
  64167. lineSpacing: string | number;
  64168. /**
  64169. * Gets or sets outlineWidth of the text to display
  64170. */
  64171. /**
  64172. * Gets or sets outlineWidth of the text to display
  64173. */
  64174. outlineWidth: number;
  64175. /**
  64176. * Gets or sets outlineColor of the text to display
  64177. */
  64178. /**
  64179. * Gets or sets outlineColor of the text to display
  64180. */
  64181. outlineColor: string;
  64182. /**
  64183. * Creates a new TextBlock object
  64184. * @param name defines the name of the control
  64185. * @param text defines the text to display (emptry string by default)
  64186. */
  64187. constructor(
  64188. /**
  64189. * Defines the name of the control
  64190. */
  64191. name?: string | undefined, text?: string);
  64192. protected _getTypeName(): string;
  64193. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64194. private _drawText;
  64195. /** @hidden */
  64196. _draw(context: CanvasRenderingContext2D): void;
  64197. protected _applyStates(context: CanvasRenderingContext2D): void;
  64198. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64199. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64200. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64201. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64202. protected _renderLines(context: CanvasRenderingContext2D): void;
  64203. /**
  64204. * Given a width constraint applied on the text block, find the expected height
  64205. * @returns expected height
  64206. */
  64207. computeExpectedHeight(): number;
  64208. dispose(): void;
  64209. }
  64210. }
  64211. declare module BABYLON.GUI {
  64212. /**
  64213. * Class used to create 2D images
  64214. */
  64215. export class Image extends Control {
  64216. name?: string | undefined;
  64217. private static _WorkingCanvas;
  64218. private _domImage;
  64219. private _imageWidth;
  64220. private _imageHeight;
  64221. private _loaded;
  64222. private _stretch;
  64223. private _source;
  64224. private _autoScale;
  64225. private _sourceLeft;
  64226. private _sourceTop;
  64227. private _sourceWidth;
  64228. private _sourceHeight;
  64229. private _cellWidth;
  64230. private _cellHeight;
  64231. private _cellId;
  64232. private _populateNinePatchSlicesFromImage;
  64233. private _sliceLeft;
  64234. private _sliceRight;
  64235. private _sliceTop;
  64236. private _sliceBottom;
  64237. private _detectPointerOnOpaqueOnly;
  64238. /**
  64239. * BABYLON.Observable notified when the content is loaded
  64240. */
  64241. onImageLoadedObservable: BABYLON.Observable<Image>;
  64242. /**
  64243. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64244. */
  64245. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64246. /**
  64247. * Gets a boolean indicating that the content is loaded
  64248. */
  64249. readonly isLoaded: boolean;
  64250. /**
  64251. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64252. */
  64253. populateNinePatchSlicesFromImage: boolean;
  64254. /**
  64255. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64256. * Beware using this as this will comsume more memory as the image has to be stored twice
  64257. */
  64258. detectPointerOnOpaqueOnly: boolean;
  64259. /**
  64260. * Gets or sets the left value for slicing (9-patch)
  64261. */
  64262. sliceLeft: number;
  64263. /**
  64264. * Gets or sets the right value for slicing (9-patch)
  64265. */
  64266. sliceRight: number;
  64267. /**
  64268. * Gets or sets the top value for slicing (9-patch)
  64269. */
  64270. sliceTop: number;
  64271. /**
  64272. * Gets or sets the bottom value for slicing (9-patch)
  64273. */
  64274. sliceBottom: number;
  64275. /**
  64276. * Gets or sets the left coordinate in the source image
  64277. */
  64278. sourceLeft: number;
  64279. /**
  64280. * Gets or sets the top coordinate in the source image
  64281. */
  64282. sourceTop: number;
  64283. /**
  64284. * Gets or sets the width to capture in the source image
  64285. */
  64286. sourceWidth: number;
  64287. /**
  64288. * Gets or sets the height to capture in the source image
  64289. */
  64290. sourceHeight: number;
  64291. /**
  64292. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64293. * @see http://doc.babylonjs.com/how_to/gui#image
  64294. */
  64295. autoScale: boolean;
  64296. /** Gets or sets the streching mode used by the image */
  64297. stretch: number;
  64298. /**
  64299. * Gets or sets the internal DOM image used to render the control
  64300. */
  64301. domImage: HTMLImageElement;
  64302. private _onImageLoaded;
  64303. private _extractNinePatchSliceDataFromImage;
  64304. /**
  64305. * Gets or sets image source url
  64306. */
  64307. source: BABYLON.Nullable<string>;
  64308. /**
  64309. * Checks for svg document with icon id present
  64310. */
  64311. private _svgCheck;
  64312. /**
  64313. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64314. * given external svg file and icon id
  64315. */
  64316. private _getSVGAttribs;
  64317. /**
  64318. * Gets or sets the cell width to use when animation sheet is enabled
  64319. * @see http://doc.babylonjs.com/how_to/gui#image
  64320. */
  64321. cellWidth: number;
  64322. /**
  64323. * Gets or sets the cell height to use when animation sheet is enabled
  64324. * @see http://doc.babylonjs.com/how_to/gui#image
  64325. */
  64326. cellHeight: number;
  64327. /**
  64328. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64329. * @see http://doc.babylonjs.com/how_to/gui#image
  64330. */
  64331. cellId: number;
  64332. /**
  64333. * Creates a new Image
  64334. * @param name defines the control name
  64335. * @param url defines the image url
  64336. */
  64337. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64338. /**
  64339. * Tests if a given coordinates belong to the current control
  64340. * @param x defines x coordinate to test
  64341. * @param y defines y coordinate to test
  64342. * @returns true if the coordinates are inside the control
  64343. */
  64344. contains(x: number, y: number): boolean;
  64345. protected _getTypeName(): string;
  64346. /** Force the control to synchronize with its content */
  64347. synchronizeSizeWithContent(): void;
  64348. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64349. private _prepareWorkingCanvasForOpaqueDetection;
  64350. private _drawImage;
  64351. _draw(context: CanvasRenderingContext2D): void;
  64352. private _renderCornerPatch;
  64353. private _renderNinePatch;
  64354. dispose(): void;
  64355. /** STRETCH_NONE */
  64356. static readonly STRETCH_NONE: number;
  64357. /** STRETCH_FILL */
  64358. static readonly STRETCH_FILL: number;
  64359. /** STRETCH_UNIFORM */
  64360. static readonly STRETCH_UNIFORM: number;
  64361. /** STRETCH_EXTEND */
  64362. static readonly STRETCH_EXTEND: number;
  64363. /** NINE_PATCH */
  64364. static readonly STRETCH_NINE_PATCH: number;
  64365. }
  64366. }
  64367. declare module BABYLON.GUI {
  64368. /**
  64369. * Class used to create 2D buttons
  64370. */
  64371. export class Button extends Rectangle {
  64372. name?: string | undefined;
  64373. /**
  64374. * Function called to generate a pointer enter animation
  64375. */
  64376. pointerEnterAnimation: () => void;
  64377. /**
  64378. * Function called to generate a pointer out animation
  64379. */
  64380. pointerOutAnimation: () => void;
  64381. /**
  64382. * Function called to generate a pointer down animation
  64383. */
  64384. pointerDownAnimation: () => void;
  64385. /**
  64386. * Function called to generate a pointer up animation
  64387. */
  64388. pointerUpAnimation: () => void;
  64389. /**
  64390. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64391. */
  64392. delegatePickingToChildren: boolean;
  64393. private _image;
  64394. /**
  64395. * Returns the image part of the button (if any)
  64396. */
  64397. readonly image: BABYLON.Nullable<Image>;
  64398. private _textBlock;
  64399. /**
  64400. * Returns the image part of the button (if any)
  64401. */
  64402. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64403. /**
  64404. * Creates a new Button
  64405. * @param name defines the name of the button
  64406. */
  64407. constructor(name?: string | undefined);
  64408. protected _getTypeName(): string;
  64409. /** @hidden */
  64410. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64411. /** @hidden */
  64412. _onPointerEnter(target: Control): boolean;
  64413. /** @hidden */
  64414. _onPointerOut(target: Control, force?: boolean): void;
  64415. /** @hidden */
  64416. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64417. /** @hidden */
  64418. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64419. /**
  64420. * Creates a new button made with an image and a text
  64421. * @param name defines the name of the button
  64422. * @param text defines the text of the button
  64423. * @param imageUrl defines the url of the image
  64424. * @returns a new Button
  64425. */
  64426. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64427. /**
  64428. * Creates a new button made with an image
  64429. * @param name defines the name of the button
  64430. * @param imageUrl defines the url of the image
  64431. * @returns a new Button
  64432. */
  64433. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64434. /**
  64435. * Creates a new button made with a text
  64436. * @param name defines the name of the button
  64437. * @param text defines the text of the button
  64438. * @returns a new Button
  64439. */
  64440. static CreateSimpleButton(name: string, text: string): Button;
  64441. /**
  64442. * Creates a new button made with an image and a centered text
  64443. * @param name defines the name of the button
  64444. * @param text defines the text of the button
  64445. * @param imageUrl defines the url of the image
  64446. * @returns a new Button
  64447. */
  64448. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64449. }
  64450. }
  64451. declare module BABYLON.GUI {
  64452. /**
  64453. * Class used to create a 2D stack panel container
  64454. */
  64455. export class StackPanel extends Container {
  64456. name?: string | undefined;
  64457. private _isVertical;
  64458. private _manualWidth;
  64459. private _manualHeight;
  64460. private _doNotTrackManualChanges;
  64461. /**
  64462. * Gets or sets a boolean indicating that layou warnings should be ignored
  64463. */
  64464. ignoreLayoutWarnings: boolean;
  64465. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64466. isVertical: boolean;
  64467. /**
  64468. * Gets or sets panel width.
  64469. * This value should not be set when in horizontal mode as it will be computed automatically
  64470. */
  64471. width: string | number;
  64472. /**
  64473. * Gets or sets panel height.
  64474. * This value should not be set when in vertical mode as it will be computed automatically
  64475. */
  64476. height: string | number;
  64477. /**
  64478. * Creates a new StackPanel
  64479. * @param name defines control name
  64480. */
  64481. constructor(name?: string | undefined);
  64482. protected _getTypeName(): string;
  64483. /** @hidden */
  64484. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64485. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64486. protected _postMeasure(): void;
  64487. }
  64488. }
  64489. declare module BABYLON.GUI {
  64490. /**
  64491. * Class used to represent a 2D checkbox
  64492. */
  64493. export class Checkbox extends Control {
  64494. name?: string | undefined;
  64495. private _isChecked;
  64496. private _background;
  64497. private _checkSizeRatio;
  64498. private _thickness;
  64499. /** Gets or sets border thickness */
  64500. thickness: number;
  64501. /**
  64502. * BABYLON.Observable raised when isChecked property changes
  64503. */
  64504. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64505. /** Gets or sets a value indicating the ratio between overall size and check size */
  64506. checkSizeRatio: number;
  64507. /** Gets or sets background color */
  64508. background: string;
  64509. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64510. isChecked: boolean;
  64511. /**
  64512. * Creates a new CheckBox
  64513. * @param name defines the control name
  64514. */
  64515. constructor(name?: string | undefined);
  64516. protected _getTypeName(): string;
  64517. /** @hidden */
  64518. _draw(context: CanvasRenderingContext2D): void;
  64519. /** @hidden */
  64520. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64521. /**
  64522. * Utility function to easily create a checkbox with a header
  64523. * @param title defines the label to use for the header
  64524. * @param onValueChanged defines the callback to call when value changes
  64525. * @returns a StackPanel containing the checkbox and a textBlock
  64526. */
  64527. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64528. }
  64529. }
  64530. declare module BABYLON.GUI {
  64531. /**
  64532. * Class used to store key control properties
  64533. */
  64534. export class KeyPropertySet {
  64535. /** Width */
  64536. width?: string;
  64537. /** Height */
  64538. height?: string;
  64539. /** Left padding */
  64540. paddingLeft?: string;
  64541. /** Right padding */
  64542. paddingRight?: string;
  64543. /** Top padding */
  64544. paddingTop?: string;
  64545. /** Bottom padding */
  64546. paddingBottom?: string;
  64547. /** Foreground color */
  64548. color?: string;
  64549. /** Background color */
  64550. background?: string;
  64551. }
  64552. /**
  64553. * Class used to create virtual keyboard
  64554. */
  64555. export class VirtualKeyboard extends StackPanel {
  64556. /** BABYLON.Observable raised when a key is pressed */
  64557. onKeyPressObservable: BABYLON.Observable<string>;
  64558. /** Gets or sets default key button width */
  64559. defaultButtonWidth: string;
  64560. /** Gets or sets default key button height */
  64561. defaultButtonHeight: string;
  64562. /** Gets or sets default key button left padding */
  64563. defaultButtonPaddingLeft: string;
  64564. /** Gets or sets default key button right padding */
  64565. defaultButtonPaddingRight: string;
  64566. /** Gets or sets default key button top padding */
  64567. defaultButtonPaddingTop: string;
  64568. /** Gets or sets default key button bottom padding */
  64569. defaultButtonPaddingBottom: string;
  64570. /** Gets or sets default key button foreground color */
  64571. defaultButtonColor: string;
  64572. /** Gets or sets default key button background color */
  64573. defaultButtonBackground: string;
  64574. /** Gets or sets shift button foreground color */
  64575. shiftButtonColor: string;
  64576. /** Gets or sets shift button thickness*/
  64577. selectedShiftThickness: number;
  64578. /** Gets shift key state */
  64579. shiftState: number;
  64580. protected _getTypeName(): string;
  64581. private _createKey;
  64582. /**
  64583. * Adds a new row of keys
  64584. * @param keys defines the list of keys to add
  64585. * @param propertySets defines the associated property sets
  64586. */
  64587. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64588. /**
  64589. * Set the shift key to a specific state
  64590. * @param shiftState defines the new shift state
  64591. */
  64592. applyShiftState(shiftState: number): void;
  64593. private _currentlyConnectedInputText;
  64594. private _connectedInputTexts;
  64595. private _onKeyPressObserver;
  64596. /** Gets the input text control currently attached to the keyboard */
  64597. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64598. /**
  64599. * Connects the keyboard with an input text control
  64600. *
  64601. * @param input defines the target control
  64602. */
  64603. connect(input: InputText): void;
  64604. /**
  64605. * Disconnects the keyboard from connected InputText controls
  64606. *
  64607. * @param input optionally defines a target control, otherwise all are disconnected
  64608. */
  64609. disconnect(input?: InputText): void;
  64610. private _removeConnectedInputObservables;
  64611. /**
  64612. * Release all resources
  64613. */
  64614. dispose(): void;
  64615. /**
  64616. * Creates a new keyboard using a default layout
  64617. *
  64618. * @param name defines control name
  64619. * @returns a new VirtualKeyboard
  64620. */
  64621. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64622. }
  64623. }
  64624. declare module BABYLON.GUI {
  64625. /**
  64626. * Class used to create input text control
  64627. */
  64628. export class InputText extends Control implements IFocusableControl {
  64629. name?: string | undefined;
  64630. private _text;
  64631. private _placeholderText;
  64632. private _background;
  64633. private _focusedBackground;
  64634. private _focusedColor;
  64635. private _placeholderColor;
  64636. private _thickness;
  64637. private _margin;
  64638. private _autoStretchWidth;
  64639. private _maxWidth;
  64640. private _isFocused;
  64641. private _blinkTimeout;
  64642. private _blinkIsEven;
  64643. private _cursorOffset;
  64644. private _scrollLeft;
  64645. private _textWidth;
  64646. private _clickedCoordinate;
  64647. private _deadKey;
  64648. private _addKey;
  64649. private _currentKey;
  64650. private _isTextHighlightOn;
  64651. private _textHighlightColor;
  64652. private _highligherOpacity;
  64653. private _highlightedText;
  64654. private _startHighlightIndex;
  64655. private _endHighlightIndex;
  64656. private _cursorIndex;
  64657. private _onFocusSelectAll;
  64658. private _isPointerDown;
  64659. private _onClipboardObserver;
  64660. private _onPointerDblTapObserver;
  64661. /** @hidden */
  64662. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64663. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64664. promptMessage: string;
  64665. /** Force disable prompt on mobile device */
  64666. disableMobilePrompt: boolean;
  64667. /** BABYLON.Observable raised when the text changes */
  64668. onTextChangedObservable: BABYLON.Observable<InputText>;
  64669. /** BABYLON.Observable raised just before an entered character is to be added */
  64670. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64671. /** BABYLON.Observable raised when the control gets the focus */
  64672. onFocusObservable: BABYLON.Observable<InputText>;
  64673. /** BABYLON.Observable raised when the control loses the focus */
  64674. onBlurObservable: BABYLON.Observable<InputText>;
  64675. /**Observable raised when the text is highlighted */
  64676. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64677. /**Observable raised when copy event is triggered */
  64678. onTextCopyObservable: BABYLON.Observable<InputText>;
  64679. /** BABYLON.Observable raised when cut event is triggered */
  64680. onTextCutObservable: BABYLON.Observable<InputText>;
  64681. /** BABYLON.Observable raised when paste event is triggered */
  64682. onTextPasteObservable: BABYLON.Observable<InputText>;
  64683. /** BABYLON.Observable raised when a key event was processed */
  64684. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64685. /** Gets or sets the maximum width allowed by the control */
  64686. maxWidth: string | number;
  64687. /** Gets the maximum width allowed by the control in pixels */
  64688. readonly maxWidthInPixels: number;
  64689. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64690. highligherOpacity: number;
  64691. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64692. onFocusSelectAll: boolean;
  64693. /** Gets or sets the text hightlight color */
  64694. textHighlightColor: string;
  64695. /** Gets or sets control margin */
  64696. margin: string;
  64697. /** Gets control margin in pixels */
  64698. readonly marginInPixels: number;
  64699. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64700. autoStretchWidth: boolean;
  64701. /** Gets or sets border thickness */
  64702. thickness: number;
  64703. /** Gets or sets the background color when focused */
  64704. focusedBackground: string;
  64705. /** Gets or sets the background color when focused */
  64706. focusedColor: string;
  64707. /** Gets or sets the background color */
  64708. background: string;
  64709. /** Gets or sets the placeholder color */
  64710. placeholderColor: string;
  64711. /** Gets or sets the text displayed when the control is empty */
  64712. placeholderText: string;
  64713. /** Gets or sets the dead key flag */
  64714. deadKey: boolean;
  64715. /** Gets or sets the highlight text */
  64716. highlightedText: string;
  64717. /** Gets or sets if the current key should be added */
  64718. addKey: boolean;
  64719. /** Gets or sets the value of the current key being entered */
  64720. currentKey: string;
  64721. /** Gets or sets the text displayed in the control */
  64722. text: string;
  64723. /** Gets or sets control width */
  64724. width: string | number;
  64725. /**
  64726. * Creates a new InputText
  64727. * @param name defines the control name
  64728. * @param text defines the text of the control
  64729. */
  64730. constructor(name?: string | undefined, text?: string);
  64731. /** @hidden */
  64732. onBlur(): void;
  64733. /** @hidden */
  64734. onFocus(): void;
  64735. protected _getTypeName(): string;
  64736. /**
  64737. * Function called to get the list of controls that should not steal the focus from this control
  64738. * @returns an array of controls
  64739. */
  64740. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64741. /** @hidden */
  64742. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64743. /** @hidden */
  64744. private _updateValueFromCursorIndex;
  64745. /** @hidden */
  64746. private _processDblClick;
  64747. /** @hidden */
  64748. private _selectAllText;
  64749. /**
  64750. * Handles the keyboard event
  64751. * @param evt Defines the KeyboardEvent
  64752. */
  64753. processKeyboard(evt: KeyboardEvent): void;
  64754. /** @hidden */
  64755. private _onCopyText;
  64756. /** @hidden */
  64757. private _onCutText;
  64758. /** @hidden */
  64759. private _onPasteText;
  64760. _draw(context: CanvasRenderingContext2D): void;
  64761. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64762. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64763. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64764. protected _beforeRenderText(text: string): string;
  64765. dispose(): void;
  64766. }
  64767. }
  64768. declare module BABYLON.GUI {
  64769. /**
  64770. * Class used to create a 2D grid container
  64771. */
  64772. export class Grid extends Container {
  64773. name?: string | undefined;
  64774. private _rowDefinitions;
  64775. private _columnDefinitions;
  64776. private _cells;
  64777. private _childControls;
  64778. /**
  64779. * Gets the number of columns
  64780. */
  64781. readonly columnCount: number;
  64782. /**
  64783. * Gets the number of rows
  64784. */
  64785. readonly rowCount: number;
  64786. /** Gets the list of children */
  64787. readonly children: Control[];
  64788. /** Gets the list of cells (e.g. the containers) */
  64789. readonly cells: {
  64790. [key: string]: Container;
  64791. };
  64792. /**
  64793. * Gets the definition of a specific row
  64794. * @param index defines the index of the row
  64795. * @returns the row definition
  64796. */
  64797. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64798. /**
  64799. * Gets the definition of a specific column
  64800. * @param index defines the index of the column
  64801. * @returns the column definition
  64802. */
  64803. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64804. /**
  64805. * Adds a new row to the grid
  64806. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64807. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64808. * @returns the current grid
  64809. */
  64810. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64811. /**
  64812. * Adds a new column to the grid
  64813. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64814. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64815. * @returns the current grid
  64816. */
  64817. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64818. /**
  64819. * Update a row definition
  64820. * @param index defines the index of the row to update
  64821. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64822. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64823. * @returns the current grid
  64824. */
  64825. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64826. /**
  64827. * Update a column definition
  64828. * @param index defines the index of the column to update
  64829. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64830. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64831. * @returns the current grid
  64832. */
  64833. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64834. /**
  64835. * Gets the list of children stored in a specific cell
  64836. * @param row defines the row to check
  64837. * @param column defines the column to check
  64838. * @returns the list of controls
  64839. */
  64840. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64841. /**
  64842. * Gets a string representing the child cell info (row x column)
  64843. * @param child defines the control to get info from
  64844. * @returns a string containing the child cell info (row x column)
  64845. */
  64846. getChildCellInfo(child: Control): string;
  64847. private _removeCell;
  64848. private _offsetCell;
  64849. /**
  64850. * Remove a column definition at specified index
  64851. * @param index defines the index of the column to remove
  64852. * @returns the current grid
  64853. */
  64854. removeColumnDefinition(index: number): Grid;
  64855. /**
  64856. * Remove a row definition at specified index
  64857. * @param index defines the index of the row to remove
  64858. * @returns the current grid
  64859. */
  64860. removeRowDefinition(index: number): Grid;
  64861. /**
  64862. * Adds a new control to the current grid
  64863. * @param control defines the control to add
  64864. * @param row defines the row where to add the control (0 by default)
  64865. * @param column defines the column where to add the control (0 by default)
  64866. * @returns the current grid
  64867. */
  64868. addControl(control: Control, row?: number, column?: number): Grid;
  64869. /**
  64870. * Removes a control from the current container
  64871. * @param control defines the control to remove
  64872. * @returns the current container
  64873. */
  64874. removeControl(control: Control): Container;
  64875. /**
  64876. * Creates a new Grid
  64877. * @param name defines control name
  64878. */
  64879. constructor(name?: string | undefined);
  64880. protected _getTypeName(): string;
  64881. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64882. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64883. _flagDescendantsAsMatrixDirty(): void;
  64884. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64885. /** Releases associated resources */
  64886. dispose(): void;
  64887. }
  64888. }
  64889. declare module BABYLON.GUI {
  64890. /** Class used to create color pickers */
  64891. export class ColorPicker extends Control {
  64892. name?: string | undefined;
  64893. private static _Epsilon;
  64894. private _colorWheelCanvas;
  64895. private _value;
  64896. private _tmpColor;
  64897. private _pointerStartedOnSquare;
  64898. private _pointerStartedOnWheel;
  64899. private _squareLeft;
  64900. private _squareTop;
  64901. private _squareSize;
  64902. private _h;
  64903. private _s;
  64904. private _v;
  64905. private _lastPointerDownID;
  64906. /**
  64907. * BABYLON.Observable raised when the value changes
  64908. */
  64909. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64910. /** Gets or sets the color of the color picker */
  64911. value: BABYLON.Color3;
  64912. /**
  64913. * Gets or sets control width
  64914. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64915. */
  64916. width: string | number;
  64917. /**
  64918. * Gets or sets control height
  64919. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64920. */
  64921. /** Gets or sets control height */
  64922. height: string | number;
  64923. /** Gets or sets control size */
  64924. size: string | number;
  64925. /**
  64926. * Creates a new ColorPicker
  64927. * @param name defines the control name
  64928. */
  64929. constructor(name?: string | undefined);
  64930. protected _getTypeName(): string;
  64931. /** @hidden */
  64932. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64933. private _updateSquareProps;
  64934. private _drawGradientSquare;
  64935. private _drawCircle;
  64936. private _createColorWheelCanvas;
  64937. /** @hidden */
  64938. _draw(context: CanvasRenderingContext2D): void;
  64939. private _pointerIsDown;
  64940. private _updateValueFromPointer;
  64941. private _isPointOnSquare;
  64942. private _isPointOnWheel;
  64943. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64944. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64945. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64946. /**
  64947. * This function expands the color picker by creating a color picker dialog with manual
  64948. * color value input and the ability to save colors into an array to be used later in
  64949. * subsequent launches of the dialogue.
  64950. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64951. * @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.
  64952. * @returns picked color as a hex string and the saved colors array as hex strings.
  64953. */
  64954. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64955. pickerWidth?: string;
  64956. pickerHeight?: string;
  64957. headerHeight?: string;
  64958. lastColor?: string;
  64959. swatchLimit?: number;
  64960. numSwatchesPerLine?: number;
  64961. savedColors?: Array<string>;
  64962. }): Promise<{
  64963. savedColors?: string[];
  64964. pickedColor: string;
  64965. }>;
  64966. }
  64967. }
  64968. declare module BABYLON.GUI {
  64969. /** Class used to create 2D ellipse containers */
  64970. export class Ellipse extends Container {
  64971. name?: string | undefined;
  64972. private _thickness;
  64973. /** Gets or sets border thickness */
  64974. thickness: number;
  64975. /**
  64976. * Creates a new Ellipse
  64977. * @param name defines the control name
  64978. */
  64979. constructor(name?: string | undefined);
  64980. protected _getTypeName(): string;
  64981. protected _localDraw(context: CanvasRenderingContext2D): void;
  64982. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64983. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64984. }
  64985. }
  64986. declare module BABYLON.GUI {
  64987. /**
  64988. * Class used to create a password control
  64989. */
  64990. export class InputPassword extends InputText {
  64991. protected _beforeRenderText(text: string): string;
  64992. }
  64993. }
  64994. declare module BABYLON.GUI {
  64995. /** Class used to render 2D lines */
  64996. export class Line extends Control {
  64997. name?: string | undefined;
  64998. private _lineWidth;
  64999. private _x1;
  65000. private _y1;
  65001. private _x2;
  65002. private _y2;
  65003. private _dash;
  65004. private _connectedControl;
  65005. private _connectedControlDirtyObserver;
  65006. /** Gets or sets the dash pattern */
  65007. dash: Array<number>;
  65008. /** Gets or sets the control connected with the line end */
  65009. connectedControl: Control;
  65010. /** Gets or sets start coordinates on X axis */
  65011. x1: string | number;
  65012. /** Gets or sets start coordinates on Y axis */
  65013. y1: string | number;
  65014. /** Gets or sets end coordinates on X axis */
  65015. x2: string | number;
  65016. /** Gets or sets end coordinates on Y axis */
  65017. y2: string | number;
  65018. /** Gets or sets line width */
  65019. lineWidth: number;
  65020. /** Gets or sets horizontal alignment */
  65021. horizontalAlignment: number;
  65022. /** Gets or sets vertical alignment */
  65023. verticalAlignment: number;
  65024. private readonly _effectiveX2;
  65025. private readonly _effectiveY2;
  65026. /**
  65027. * Creates a new Line
  65028. * @param name defines the control name
  65029. */
  65030. constructor(name?: string | undefined);
  65031. protected _getTypeName(): string;
  65032. _draw(context: CanvasRenderingContext2D): void;
  65033. _measure(): void;
  65034. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65035. /**
  65036. * Move one end of the line given 3D cartesian coordinates.
  65037. * @param position Targeted world position
  65038. * @param scene BABYLON.Scene
  65039. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65040. */
  65041. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65042. /**
  65043. * Move one end of the line to a position in screen absolute space.
  65044. * @param projectedPosition Position in screen absolute space (X, Y)
  65045. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65046. */
  65047. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65048. }
  65049. }
  65050. declare module BABYLON.GUI {
  65051. /**
  65052. * Class used to store a point for a MultiLine object.
  65053. * The point can be pure 2D coordinates, a mesh or a control
  65054. */
  65055. export class MultiLinePoint {
  65056. private _multiLine;
  65057. private _x;
  65058. private _y;
  65059. private _control;
  65060. private _mesh;
  65061. private _controlObserver;
  65062. private _meshObserver;
  65063. /** @hidden */
  65064. _point: BABYLON.Vector2;
  65065. /**
  65066. * Creates a new MultiLinePoint
  65067. * @param multiLine defines the source MultiLine object
  65068. */
  65069. constructor(multiLine: MultiLine);
  65070. /** Gets or sets x coordinate */
  65071. x: string | number;
  65072. /** Gets or sets y coordinate */
  65073. y: string | number;
  65074. /** Gets or sets the control associated with this point */
  65075. control: BABYLON.Nullable<Control>;
  65076. /** Gets or sets the mesh associated with this point */
  65077. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65078. /** Resets links */
  65079. resetLinks(): void;
  65080. /**
  65081. * Gets a translation vector
  65082. * @returns the translation vector
  65083. */
  65084. translate(): BABYLON.Vector2;
  65085. private _translatePoint;
  65086. /** Release associated resources */
  65087. dispose(): void;
  65088. }
  65089. }
  65090. declare module BABYLON.GUI {
  65091. /**
  65092. * Class used to create multi line control
  65093. */
  65094. export class MultiLine extends Control {
  65095. name?: string | undefined;
  65096. private _lineWidth;
  65097. private _dash;
  65098. private _points;
  65099. private _minX;
  65100. private _minY;
  65101. private _maxX;
  65102. private _maxY;
  65103. /**
  65104. * Creates a new MultiLine
  65105. * @param name defines the control name
  65106. */
  65107. constructor(name?: string | undefined);
  65108. /** Gets or sets dash pattern */
  65109. dash: Array<number>;
  65110. /**
  65111. * Gets point stored at specified index
  65112. * @param index defines the index to look for
  65113. * @returns the requested point if found
  65114. */
  65115. getAt(index: number): MultiLinePoint;
  65116. /** Function called when a point is updated */
  65117. onPointUpdate: () => void;
  65118. /**
  65119. * Adds new points to the point collection
  65120. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65121. * @returns the list of created MultiLinePoint
  65122. */
  65123. add(...items: (AbstractMesh | Control | {
  65124. x: string | number;
  65125. y: string | number;
  65126. })[]): MultiLinePoint[];
  65127. /**
  65128. * Adds a new point to the point collection
  65129. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65130. * @returns the created MultiLinePoint
  65131. */
  65132. push(item?: (AbstractMesh | Control | {
  65133. x: string | number;
  65134. y: string | number;
  65135. })): MultiLinePoint;
  65136. /**
  65137. * Remove a specific value or point from the active point collection
  65138. * @param value defines the value or point to remove
  65139. */
  65140. remove(value: number | MultiLinePoint): void;
  65141. /**
  65142. * Resets this object to initial state (no point)
  65143. */
  65144. reset(): void;
  65145. /**
  65146. * Resets all links
  65147. */
  65148. resetLinks(): void;
  65149. /** Gets or sets line width */
  65150. lineWidth: number;
  65151. horizontalAlignment: number;
  65152. verticalAlignment: number;
  65153. protected _getTypeName(): string;
  65154. _draw(context: CanvasRenderingContext2D): void;
  65155. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65156. _measure(): void;
  65157. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65158. dispose(): void;
  65159. }
  65160. }
  65161. declare module BABYLON.GUI {
  65162. /**
  65163. * Class used to create radio button controls
  65164. */
  65165. export class RadioButton extends Control {
  65166. name?: string | undefined;
  65167. private _isChecked;
  65168. private _background;
  65169. private _checkSizeRatio;
  65170. private _thickness;
  65171. /** Gets or sets border thickness */
  65172. thickness: number;
  65173. /** Gets or sets group name */
  65174. group: string;
  65175. /** BABYLON.Observable raised when isChecked is changed */
  65176. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65177. /** Gets or sets a value indicating the ratio between overall size and check size */
  65178. checkSizeRatio: number;
  65179. /** Gets or sets background color */
  65180. background: string;
  65181. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65182. isChecked: boolean;
  65183. /**
  65184. * Creates a new RadioButton
  65185. * @param name defines the control name
  65186. */
  65187. constructor(name?: string | undefined);
  65188. protected _getTypeName(): string;
  65189. _draw(context: CanvasRenderingContext2D): void;
  65190. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65191. /**
  65192. * Utility function to easily create a radio button with a header
  65193. * @param title defines the label to use for the header
  65194. * @param group defines the group to use for the radio button
  65195. * @param isChecked defines the initial state of the radio button
  65196. * @param onValueChanged defines the callback to call when value changes
  65197. * @returns a StackPanel containing the radio button and a textBlock
  65198. */
  65199. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65200. }
  65201. }
  65202. declare module BABYLON.GUI {
  65203. /**
  65204. * Class used to create slider controls
  65205. */
  65206. export class BaseSlider extends Control {
  65207. name?: string | undefined;
  65208. protected _thumbWidth: ValueAndUnit;
  65209. private _minimum;
  65210. private _maximum;
  65211. private _value;
  65212. private _isVertical;
  65213. protected _barOffset: ValueAndUnit;
  65214. private _isThumbClamped;
  65215. protected _displayThumb: boolean;
  65216. private _step;
  65217. private _lastPointerDownID;
  65218. protected _effectiveBarOffset: number;
  65219. protected _renderLeft: number;
  65220. protected _renderTop: number;
  65221. protected _renderWidth: number;
  65222. protected _renderHeight: number;
  65223. protected _backgroundBoxLength: number;
  65224. protected _backgroundBoxThickness: number;
  65225. protected _effectiveThumbThickness: number;
  65226. /** BABYLON.Observable raised when the sldier value changes */
  65227. onValueChangedObservable: BABYLON.Observable<number>;
  65228. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65229. displayThumb: boolean;
  65230. /** Gets or sets a step to apply to values (0 by default) */
  65231. step: number;
  65232. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65233. barOffset: string | number;
  65234. /** Gets main bar offset in pixels*/
  65235. readonly barOffsetInPixels: number;
  65236. /** Gets or sets thumb width */
  65237. thumbWidth: string | number;
  65238. /** Gets thumb width in pixels */
  65239. readonly thumbWidthInPixels: number;
  65240. /** Gets or sets minimum value */
  65241. minimum: number;
  65242. /** Gets or sets maximum value */
  65243. maximum: number;
  65244. /** Gets or sets current value */
  65245. value: number;
  65246. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65247. isVertical: boolean;
  65248. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65249. isThumbClamped: boolean;
  65250. /**
  65251. * Creates a new BaseSlider
  65252. * @param name defines the control name
  65253. */
  65254. constructor(name?: string | undefined);
  65255. protected _getTypeName(): string;
  65256. protected _getThumbPosition(): number;
  65257. protected _getThumbThickness(type: string): number;
  65258. protected _prepareRenderingData(type: string): void;
  65259. private _pointerIsDown;
  65260. /** @hidden */
  65261. protected _updateValueFromPointer(x: number, y: number): void;
  65262. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65263. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65264. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65265. }
  65266. }
  65267. declare module BABYLON.GUI {
  65268. /**
  65269. * Class used to create slider controls
  65270. */
  65271. export class Slider extends BaseSlider {
  65272. name?: string | undefined;
  65273. private _background;
  65274. private _borderColor;
  65275. private _isThumbCircle;
  65276. protected _displayValueBar: boolean;
  65277. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65278. displayValueBar: boolean;
  65279. /** Gets or sets border color */
  65280. borderColor: string;
  65281. /** Gets or sets background color */
  65282. background: string;
  65283. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65284. isThumbCircle: boolean;
  65285. /**
  65286. * Creates a new Slider
  65287. * @param name defines the control name
  65288. */
  65289. constructor(name?: string | undefined);
  65290. protected _getTypeName(): string;
  65291. _draw(context: CanvasRenderingContext2D): void;
  65292. }
  65293. }
  65294. declare module BABYLON.GUI {
  65295. /** Class used to create a RadioGroup
  65296. * which contains groups of radio buttons
  65297. */
  65298. export class SelectorGroup {
  65299. /** name of SelectorGroup */
  65300. name: string;
  65301. private _groupPanel;
  65302. private _selectors;
  65303. private _groupHeader;
  65304. /**
  65305. * Creates a new SelectorGroup
  65306. * @param name of group, used as a group heading
  65307. */
  65308. constructor(
  65309. /** name of SelectorGroup */
  65310. name: string);
  65311. /** Gets the groupPanel of the SelectorGroup */
  65312. readonly groupPanel: StackPanel;
  65313. /** Gets the selectors array */
  65314. readonly selectors: StackPanel[];
  65315. /** Gets and sets the group header */
  65316. header: string;
  65317. /** @hidden */
  65318. private _addGroupHeader;
  65319. /** @hidden*/
  65320. _getSelector(selectorNb: number): StackPanel | undefined;
  65321. /** Removes the selector at the given position
  65322. * @param selectorNb the position of the selector within the group
  65323. */
  65324. removeSelector(selectorNb: number): void;
  65325. }
  65326. /** Class used to create a CheckboxGroup
  65327. * which contains groups of checkbox buttons
  65328. */
  65329. export class CheckboxGroup extends SelectorGroup {
  65330. /** Adds a checkbox as a control
  65331. * @param text is the label for the selector
  65332. * @param func is the function called when the Selector is checked
  65333. * @param checked is true when Selector is checked
  65334. */
  65335. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65336. /** @hidden */
  65337. _setSelectorLabel(selectorNb: number, label: string): void;
  65338. /** @hidden */
  65339. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65340. /** @hidden */
  65341. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65342. /** @hidden */
  65343. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65344. }
  65345. /** Class used to create a RadioGroup
  65346. * which contains groups of radio buttons
  65347. */
  65348. export class RadioGroup extends SelectorGroup {
  65349. private _selectNb;
  65350. /** Adds a radio button as a control
  65351. * @param label is the label for the selector
  65352. * @param func is the function called when the Selector is checked
  65353. * @param checked is true when Selector is checked
  65354. */
  65355. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65356. /** @hidden */
  65357. _setSelectorLabel(selectorNb: number, label: string): void;
  65358. /** @hidden */
  65359. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65360. /** @hidden */
  65361. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65362. /** @hidden */
  65363. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65364. }
  65365. /** Class used to create a SliderGroup
  65366. * which contains groups of slider buttons
  65367. */
  65368. export class SliderGroup extends SelectorGroup {
  65369. /**
  65370. * Adds a slider to the SelectorGroup
  65371. * @param label is the label for the SliderBar
  65372. * @param func is the function called when the Slider moves
  65373. * @param unit is a string describing the units used, eg degrees or metres
  65374. * @param min is the minimum value for the Slider
  65375. * @param max is the maximum value for the Slider
  65376. * @param value is the start value for the Slider between min and max
  65377. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65378. */
  65379. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65380. /** @hidden */
  65381. _setSelectorLabel(selectorNb: number, label: string): void;
  65382. /** @hidden */
  65383. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65384. /** @hidden */
  65385. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65386. /** @hidden */
  65387. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65388. }
  65389. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65390. * @see http://doc.babylonjs.com/how_to/selector
  65391. */
  65392. export class SelectionPanel extends Rectangle {
  65393. /** name of SelectionPanel */
  65394. name: string;
  65395. /** an array of SelectionGroups */
  65396. groups: SelectorGroup[];
  65397. private _panel;
  65398. private _buttonColor;
  65399. private _buttonBackground;
  65400. private _headerColor;
  65401. private _barColor;
  65402. private _barHeight;
  65403. private _spacerHeight;
  65404. private _labelColor;
  65405. private _groups;
  65406. private _bars;
  65407. /**
  65408. * Creates a new SelectionPanel
  65409. * @param name of SelectionPanel
  65410. * @param groups is an array of SelectionGroups
  65411. */
  65412. constructor(
  65413. /** name of SelectionPanel */
  65414. name: string,
  65415. /** an array of SelectionGroups */
  65416. groups?: SelectorGroup[]);
  65417. protected _getTypeName(): string;
  65418. /** Gets or sets the headerColor */
  65419. headerColor: string;
  65420. private _setHeaderColor;
  65421. /** Gets or sets the button color */
  65422. buttonColor: string;
  65423. private _setbuttonColor;
  65424. /** Gets or sets the label color */
  65425. labelColor: string;
  65426. private _setLabelColor;
  65427. /** Gets or sets the button background */
  65428. buttonBackground: string;
  65429. private _setButtonBackground;
  65430. /** Gets or sets the color of separator bar */
  65431. barColor: string;
  65432. private _setBarColor;
  65433. /** Gets or sets the height of separator bar */
  65434. barHeight: string;
  65435. private _setBarHeight;
  65436. /** Gets or sets the height of spacers*/
  65437. spacerHeight: string;
  65438. private _setSpacerHeight;
  65439. /** Adds a bar between groups */
  65440. private _addSpacer;
  65441. /** Add a group to the selection panel
  65442. * @param group is the selector group to add
  65443. */
  65444. addGroup(group: SelectorGroup): void;
  65445. /** Remove the group from the given position
  65446. * @param groupNb is the position of the group in the list
  65447. */
  65448. removeGroup(groupNb: number): void;
  65449. /** Change a group header label
  65450. * @param label is the new group header label
  65451. * @param groupNb is the number of the group to relabel
  65452. * */
  65453. setHeaderName(label: string, groupNb: number): void;
  65454. /** Change selector label to the one given
  65455. * @param label is the new selector label
  65456. * @param groupNb is the number of the groupcontaining the selector
  65457. * @param selectorNb is the number of the selector within a group to relabel
  65458. * */
  65459. relabel(label: string, groupNb: number, selectorNb: number): void;
  65460. /** For a given group position remove the selector at the given position
  65461. * @param groupNb is the number of the group to remove the selector from
  65462. * @param selectorNb is the number of the selector within the group
  65463. */
  65464. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65465. /** For a given group position of correct type add a checkbox button
  65466. * @param groupNb is the number of the group to remove the selector from
  65467. * @param label is the label for the selector
  65468. * @param func is the function called when the Selector is checked
  65469. * @param checked is true when Selector is checked
  65470. */
  65471. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65472. /** For a given group position of correct type add a radio button
  65473. * @param groupNb is the number of the group to remove the selector from
  65474. * @param label is the label for the selector
  65475. * @param func is the function called when the Selector is checked
  65476. * @param checked is true when Selector is checked
  65477. */
  65478. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65479. /**
  65480. * For a given slider group add a slider
  65481. * @param groupNb is the number of the group to add the slider to
  65482. * @param label is the label for the Slider
  65483. * @param func is the function called when the Slider moves
  65484. * @param unit is a string describing the units used, eg degrees or metres
  65485. * @param min is the minimum value for the Slider
  65486. * @param max is the maximum value for the Slider
  65487. * @param value is the start value for the Slider between min and max
  65488. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65489. */
  65490. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65491. }
  65492. }
  65493. declare module BABYLON.GUI {
  65494. /**
  65495. * Class used to hold a the container for ScrollViewer
  65496. * @hidden
  65497. */
  65498. export class _ScrollViewerWindow extends Container {
  65499. parentClientWidth: number;
  65500. parentClientHeight: number;
  65501. /**
  65502. * Creates a new ScrollViewerWindow
  65503. * @param name of ScrollViewerWindow
  65504. */
  65505. constructor(name?: string);
  65506. protected _getTypeName(): string;
  65507. /** @hidden */
  65508. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65509. protected _postMeasure(): void;
  65510. }
  65511. }
  65512. declare module BABYLON.GUI {
  65513. /**
  65514. * Class used to create slider controls
  65515. */
  65516. export class ScrollBar extends BaseSlider {
  65517. name?: string | undefined;
  65518. private _background;
  65519. private _borderColor;
  65520. private _thumbMeasure;
  65521. /** Gets or sets border color */
  65522. borderColor: string;
  65523. /** Gets or sets background color */
  65524. background: string;
  65525. /**
  65526. * Creates a new Slider
  65527. * @param name defines the control name
  65528. */
  65529. constructor(name?: string | undefined);
  65530. protected _getTypeName(): string;
  65531. protected _getThumbThickness(): number;
  65532. _draw(context: CanvasRenderingContext2D): void;
  65533. private _first;
  65534. private _originX;
  65535. private _originY;
  65536. /** @hidden */
  65537. protected _updateValueFromPointer(x: number, y: number): void;
  65538. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65539. }
  65540. }
  65541. declare module BABYLON.GUI {
  65542. /**
  65543. * Class used to hold a viewer window and sliders in a grid
  65544. */
  65545. export class ScrollViewer extends Rectangle {
  65546. private _grid;
  65547. private _horizontalBarSpace;
  65548. private _verticalBarSpace;
  65549. private _dragSpace;
  65550. private _horizontalBar;
  65551. private _verticalBar;
  65552. private _barColor;
  65553. private _barBackground;
  65554. private _barSize;
  65555. private _endLeft;
  65556. private _endTop;
  65557. private _window;
  65558. private _pointerIsOver;
  65559. private _wheelPrecision;
  65560. private _onPointerObserver;
  65561. private _clientWidth;
  65562. private _clientHeight;
  65563. /**
  65564. * Gets the horizontal scrollbar
  65565. */
  65566. readonly horizontalBar: ScrollBar;
  65567. /**
  65568. * Gets the vertical scrollbar
  65569. */
  65570. readonly verticalBar: ScrollBar;
  65571. /**
  65572. * Adds a new control to the current container
  65573. * @param control defines the control to add
  65574. * @returns the current container
  65575. */
  65576. addControl(control: BABYLON.Nullable<Control>): Container;
  65577. /**
  65578. * Removes a control from the current container
  65579. * @param control defines the control to remove
  65580. * @returns the current container
  65581. */
  65582. removeControl(control: Control): Container;
  65583. /** Gets the list of children */
  65584. readonly children: Control[];
  65585. _flagDescendantsAsMatrixDirty(): void;
  65586. /**
  65587. * Creates a new ScrollViewer
  65588. * @param name of ScrollViewer
  65589. */
  65590. constructor(name?: string);
  65591. /** Reset the scroll viewer window to initial size */
  65592. resetWindow(): void;
  65593. protected _getTypeName(): string;
  65594. private _buildClientSizes;
  65595. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65596. protected _postMeasure(): void;
  65597. /**
  65598. * Gets or sets the mouse wheel precision
  65599. * from 0 to 1 with a default value of 0.05
  65600. * */
  65601. wheelPrecision: number;
  65602. /** Gets or sets the bar color */
  65603. barColor: string;
  65604. /** Gets or sets the size of the bar */
  65605. barSize: number;
  65606. /** Gets or sets the bar background */
  65607. barBackground: string;
  65608. /** @hidden */
  65609. private _updateScroller;
  65610. _link(host: AdvancedDynamicTexture): void;
  65611. /** @hidden */
  65612. private _attachWheel;
  65613. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65614. /** Releases associated resources */
  65615. dispose(): void;
  65616. }
  65617. }
  65618. declare module BABYLON.GUI {
  65619. /** Class used to render a grid */
  65620. export class DisplayGrid extends Control {
  65621. name?: string | undefined;
  65622. private _cellWidth;
  65623. private _cellHeight;
  65624. private _minorLineTickness;
  65625. private _minorLineColor;
  65626. private _majorLineTickness;
  65627. private _majorLineColor;
  65628. private _majorLineFrequency;
  65629. private _background;
  65630. private _displayMajorLines;
  65631. private _displayMinorLines;
  65632. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65633. displayMinorLines: boolean;
  65634. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65635. displayMajorLines: boolean;
  65636. /** Gets or sets background color (Black by default) */
  65637. background: string;
  65638. /** Gets or sets the width of each cell (20 by default) */
  65639. cellWidth: number;
  65640. /** Gets or sets the height of each cell (20 by default) */
  65641. cellHeight: number;
  65642. /** Gets or sets the tickness of minor lines (1 by default) */
  65643. minorLineTickness: number;
  65644. /** Gets or sets the color of minor lines (DarkGray by default) */
  65645. minorLineColor: string;
  65646. /** Gets or sets the tickness of major lines (2 by default) */
  65647. majorLineTickness: number;
  65648. /** Gets or sets the color of major lines (White by default) */
  65649. majorLineColor: string;
  65650. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65651. majorLineFrequency: number;
  65652. /**
  65653. * Creates a new GridDisplayRectangle
  65654. * @param name defines the control name
  65655. */
  65656. constructor(name?: string | undefined);
  65657. _draw(context: CanvasRenderingContext2D): void;
  65658. protected _getTypeName(): string;
  65659. }
  65660. }
  65661. declare module BABYLON.GUI {
  65662. /**
  65663. * Class used to create slider controls based on images
  65664. */
  65665. export class ImageBasedSlider extends BaseSlider {
  65666. name?: string | undefined;
  65667. private _backgroundImage;
  65668. private _thumbImage;
  65669. private _valueBarImage;
  65670. private _tempMeasure;
  65671. displayThumb: boolean;
  65672. /**
  65673. * Gets or sets the image used to render the background
  65674. */
  65675. backgroundImage: Image;
  65676. /**
  65677. * Gets or sets the image used to render the value bar
  65678. */
  65679. valueBarImage: Image;
  65680. /**
  65681. * Gets or sets the image used to render the thumb
  65682. */
  65683. thumbImage: Image;
  65684. /**
  65685. * Creates a new ImageBasedSlider
  65686. * @param name defines the control name
  65687. */
  65688. constructor(name?: string | undefined);
  65689. protected _getTypeName(): string;
  65690. _draw(context: CanvasRenderingContext2D): void;
  65691. }
  65692. }
  65693. declare module BABYLON.GUI {
  65694. /**
  65695. * Forcing an export so that this code will execute
  65696. * @hidden
  65697. */
  65698. const name = "Statics";
  65699. }
  65700. declare module BABYLON.GUI {
  65701. /**
  65702. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65703. */
  65704. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65705. /**
  65706. * Define the instrumented AdvancedDynamicTexture.
  65707. */
  65708. texture: AdvancedDynamicTexture;
  65709. private _captureRenderTime;
  65710. private _renderTime;
  65711. private _captureLayoutTime;
  65712. private _layoutTime;
  65713. private _onBeginRenderObserver;
  65714. private _onEndRenderObserver;
  65715. private _onBeginLayoutObserver;
  65716. private _onEndLayoutObserver;
  65717. /**
  65718. * Gets the perf counter used to capture render time
  65719. */
  65720. readonly renderTimeCounter: BABYLON.PerfCounter;
  65721. /**
  65722. * Gets the perf counter used to capture layout time
  65723. */
  65724. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65725. /**
  65726. * Enable or disable the render time capture
  65727. */
  65728. captureRenderTime: boolean;
  65729. /**
  65730. * Enable or disable the layout time capture
  65731. */
  65732. captureLayoutTime: boolean;
  65733. /**
  65734. * Instantiates a new advanced dynamic texture instrumentation.
  65735. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65736. * @param texture Defines the AdvancedDynamicTexture to instrument
  65737. */
  65738. constructor(
  65739. /**
  65740. * Define the instrumented AdvancedDynamicTexture.
  65741. */
  65742. texture: AdvancedDynamicTexture);
  65743. /**
  65744. * Dispose and release associated resources.
  65745. */
  65746. dispose(): void;
  65747. }
  65748. }
  65749. declare module BABYLON.GUI {
  65750. /**
  65751. * Class used to create containers for controls
  65752. */
  65753. export class Container3D extends Control3D {
  65754. private _blockLayout;
  65755. /**
  65756. * Gets the list of child controls
  65757. */
  65758. protected _children: Control3D[];
  65759. /**
  65760. * Gets the list of child controls
  65761. */
  65762. readonly children: Array<Control3D>;
  65763. /**
  65764. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65765. * This is helpful to optimize layout operation when adding multiple children in a row
  65766. */
  65767. blockLayout: boolean;
  65768. /**
  65769. * Creates a new container
  65770. * @param name defines the container name
  65771. */
  65772. constructor(name?: string);
  65773. /**
  65774. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65775. * @returns the current container
  65776. */
  65777. updateLayout(): Container3D;
  65778. /**
  65779. * Gets a boolean indicating if the given control is in the children of this control
  65780. * @param control defines the control to check
  65781. * @returns true if the control is in the child list
  65782. */
  65783. containsControl(control: Control3D): boolean;
  65784. /**
  65785. * Adds a control to the children of this control
  65786. * @param control defines the control to add
  65787. * @returns the current container
  65788. */
  65789. addControl(control: Control3D): Container3D;
  65790. /**
  65791. * This function will be called everytime a new control is added
  65792. */
  65793. protected _arrangeChildren(): void;
  65794. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65795. /**
  65796. * Removes a control from the children of this control
  65797. * @param control defines the control to remove
  65798. * @returns the current container
  65799. */
  65800. removeControl(control: Control3D): Container3D;
  65801. protected _getTypeName(): string;
  65802. /**
  65803. * Releases all associated resources
  65804. */
  65805. dispose(): void;
  65806. /** Control rotation will remain unchanged */
  65807. static readonly UNSET_ORIENTATION: number;
  65808. /** Control will rotate to make it look at sphere central axis */
  65809. static readonly FACEORIGIN_ORIENTATION: number;
  65810. /** Control will rotate to make it look back at sphere central axis */
  65811. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65812. /** Control will rotate to look at z axis (0, 0, 1) */
  65813. static readonly FACEFORWARD_ORIENTATION: number;
  65814. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65815. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65816. }
  65817. }
  65818. declare module BABYLON.GUI {
  65819. /**
  65820. * Class used to manage 3D user interface
  65821. * @see http://doc.babylonjs.com/how_to/gui3d
  65822. */
  65823. export class GUI3DManager implements BABYLON.IDisposable {
  65824. private _scene;
  65825. private _sceneDisposeObserver;
  65826. private _utilityLayer;
  65827. private _rootContainer;
  65828. private _pointerObserver;
  65829. private _pointerOutObserver;
  65830. /** @hidden */
  65831. _lastPickedControl: Control3D;
  65832. /** @hidden */
  65833. _lastControlOver: {
  65834. [pointerId: number]: Control3D;
  65835. };
  65836. /** @hidden */
  65837. _lastControlDown: {
  65838. [pointerId: number]: Control3D;
  65839. };
  65840. /**
  65841. * BABYLON.Observable raised when the point picked by the pointer events changed
  65842. */
  65843. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65844. /** @hidden */
  65845. _sharedMaterials: {
  65846. [key: string]: BABYLON.Material;
  65847. };
  65848. /** Gets the hosting scene */
  65849. readonly scene: BABYLON.Scene;
  65850. /** Gets associated utility layer */
  65851. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65852. /**
  65853. * Creates a new GUI3DManager
  65854. * @param scene
  65855. */
  65856. constructor(scene?: BABYLON.Scene);
  65857. private _handlePointerOut;
  65858. private _doPicking;
  65859. /**
  65860. * Gets the root container
  65861. */
  65862. readonly rootContainer: Container3D;
  65863. /**
  65864. * Gets a boolean indicating if the given control is in the root child list
  65865. * @param control defines the control to check
  65866. * @returns true if the control is in the root child list
  65867. */
  65868. containsControl(control: Control3D): boolean;
  65869. /**
  65870. * Adds a control to the root child list
  65871. * @param control defines the control to add
  65872. * @returns the current manager
  65873. */
  65874. addControl(control: Control3D): GUI3DManager;
  65875. /**
  65876. * Removes a control from the root child list
  65877. * @param control defines the control to remove
  65878. * @returns the current container
  65879. */
  65880. removeControl(control: Control3D): GUI3DManager;
  65881. /**
  65882. * Releases all associated resources
  65883. */
  65884. dispose(): void;
  65885. }
  65886. }
  65887. declare module BABYLON.GUI {
  65888. /**
  65889. * Class used to transport BABYLON.Vector3 information for pointer events
  65890. */
  65891. export class Vector3WithInfo extends BABYLON.Vector3 {
  65892. /** defines the current mouse button index */
  65893. buttonIndex: number;
  65894. /**
  65895. * Creates a new Vector3WithInfo
  65896. * @param source defines the vector3 data to transport
  65897. * @param buttonIndex defines the current mouse button index
  65898. */
  65899. constructor(source: BABYLON.Vector3,
  65900. /** defines the current mouse button index */
  65901. buttonIndex?: number);
  65902. }
  65903. }
  65904. declare module BABYLON.GUI {
  65905. /**
  65906. * Class used as base class for controls
  65907. */
  65908. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65909. /** Defines the control name */
  65910. name?: string | undefined;
  65911. /** @hidden */
  65912. _host: GUI3DManager;
  65913. private _node;
  65914. private _downCount;
  65915. private _enterCount;
  65916. private _downPointerIds;
  65917. private _isVisible;
  65918. /** Gets or sets the control position in world space */
  65919. position: BABYLON.Vector3;
  65920. /** Gets or sets the control scaling in world space */
  65921. scaling: BABYLON.Vector3;
  65922. /** Callback used to start pointer enter animation */
  65923. pointerEnterAnimation: () => void;
  65924. /** Callback used to start pointer out animation */
  65925. pointerOutAnimation: () => void;
  65926. /** Callback used to start pointer down animation */
  65927. pointerDownAnimation: () => void;
  65928. /** Callback used to start pointer up animation */
  65929. pointerUpAnimation: () => void;
  65930. /**
  65931. * An event triggered when the pointer move over the control
  65932. */
  65933. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65934. /**
  65935. * An event triggered when the pointer move out of the control
  65936. */
  65937. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65938. /**
  65939. * An event triggered when the pointer taps the control
  65940. */
  65941. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65942. /**
  65943. * An event triggered when pointer is up
  65944. */
  65945. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65946. /**
  65947. * An event triggered when a control is clicked on (with a mouse)
  65948. */
  65949. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65950. /**
  65951. * An event triggered when pointer enters the control
  65952. */
  65953. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65954. /**
  65955. * Gets or sets the parent container
  65956. */
  65957. parent: BABYLON.Nullable<Container3D>;
  65958. private _behaviors;
  65959. /**
  65960. * Gets the list of attached behaviors
  65961. * @see http://doc.babylonjs.com/features/behaviour
  65962. */
  65963. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65964. /**
  65965. * Attach a behavior to the control
  65966. * @see http://doc.babylonjs.com/features/behaviour
  65967. * @param behavior defines the behavior to attach
  65968. * @returns the current control
  65969. */
  65970. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65971. /**
  65972. * Remove an attached behavior
  65973. * @see http://doc.babylonjs.com/features/behaviour
  65974. * @param behavior defines the behavior to attach
  65975. * @returns the current control
  65976. */
  65977. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65978. /**
  65979. * Gets an attached behavior by name
  65980. * @param name defines the name of the behavior to look for
  65981. * @see http://doc.babylonjs.com/features/behaviour
  65982. * @returns null if behavior was not found else the requested behavior
  65983. */
  65984. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65985. /** Gets or sets a boolean indicating if the control is visible */
  65986. isVisible: boolean;
  65987. /**
  65988. * Creates a new control
  65989. * @param name defines the control name
  65990. */
  65991. constructor(
  65992. /** Defines the control name */
  65993. name?: string | undefined);
  65994. /**
  65995. * Gets a string representing the class name
  65996. */
  65997. readonly typeName: string;
  65998. /**
  65999. * Get the current class name of the control.
  66000. * @returns current class name
  66001. */
  66002. getClassName(): string;
  66003. protected _getTypeName(): string;
  66004. /**
  66005. * Gets the transform node used by this control
  66006. */
  66007. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66008. /**
  66009. * Gets the mesh used to render this control
  66010. */
  66011. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66012. /**
  66013. * Link the control as child of the given node
  66014. * @param node defines the node to link to. Use null to unlink the control
  66015. * @returns the current control
  66016. */
  66017. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66018. /** @hidden **/
  66019. _prepareNode(scene: BABYLON.Scene): void;
  66020. /**
  66021. * Node creation.
  66022. * Can be overriden by children
  66023. * @param scene defines the scene where the node must be attached
  66024. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66025. */
  66026. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66027. /**
  66028. * Affect a material to the given mesh
  66029. * @param mesh defines the mesh which will represent the control
  66030. */
  66031. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66032. /** @hidden */
  66033. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66034. /** @hidden */
  66035. _onPointerEnter(target: Control3D): boolean;
  66036. /** @hidden */
  66037. _onPointerOut(target: Control3D): void;
  66038. /** @hidden */
  66039. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66040. /** @hidden */
  66041. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66042. /** @hidden */
  66043. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66044. /** @hidden */
  66045. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66046. /** @hidden */
  66047. _disposeNode(): void;
  66048. /**
  66049. * Releases all associated resources
  66050. */
  66051. dispose(): void;
  66052. }
  66053. }
  66054. declare module BABYLON.GUI {
  66055. /**
  66056. * Class used as a root to all buttons
  66057. */
  66058. export class AbstractButton3D extends Control3D {
  66059. /**
  66060. * Creates a new button
  66061. * @param name defines the control name
  66062. */
  66063. constructor(name?: string);
  66064. protected _getTypeName(): string;
  66065. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66066. }
  66067. }
  66068. declare module BABYLON.GUI {
  66069. /**
  66070. * Class used to create a button in 3D
  66071. */
  66072. export class Button3D extends AbstractButton3D {
  66073. /** @hidden */
  66074. protected _currentMaterial: BABYLON.Material;
  66075. private _facadeTexture;
  66076. private _content;
  66077. private _contentResolution;
  66078. private _contentScaleRatio;
  66079. /**
  66080. * Gets or sets the texture resolution used to render content (512 by default)
  66081. */
  66082. contentResolution: BABYLON.int;
  66083. /**
  66084. * Gets or sets the texture scale ratio used to render content (2 by default)
  66085. */
  66086. contentScaleRatio: number;
  66087. protected _disposeFacadeTexture(): void;
  66088. protected _resetContent(): void;
  66089. /**
  66090. * Creates a new button
  66091. * @param name defines the control name
  66092. */
  66093. constructor(name?: string);
  66094. /**
  66095. * Gets or sets the GUI 2D content used to display the button's facade
  66096. */
  66097. content: Control;
  66098. /**
  66099. * Apply the facade texture (created from the content property).
  66100. * This function can be overloaded by child classes
  66101. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66102. */
  66103. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66104. protected _getTypeName(): string;
  66105. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66106. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66107. /**
  66108. * Releases all associated resources
  66109. */
  66110. dispose(): void;
  66111. }
  66112. }
  66113. declare module BABYLON.GUI {
  66114. /**
  66115. * Abstract class used to create a container panel deployed on the surface of a volume
  66116. */
  66117. export abstract class VolumeBasedPanel extends Container3D {
  66118. private _columns;
  66119. private _rows;
  66120. private _rowThenColum;
  66121. private _orientation;
  66122. protected _cellWidth: number;
  66123. protected _cellHeight: number;
  66124. /**
  66125. * Gets or sets the distance between elements
  66126. */
  66127. margin: number;
  66128. /**
  66129. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66130. * | Value | Type | Description |
  66131. * | ----- | ----------------------------------- | ----------- |
  66132. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66133. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66134. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66135. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66136. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66137. */
  66138. orientation: number;
  66139. /**
  66140. * Gets or sets the number of columns requested (10 by default).
  66141. * The panel will automatically compute the number of rows based on number of child controls.
  66142. */
  66143. columns: BABYLON.int;
  66144. /**
  66145. * Gets or sets a the number of rows requested.
  66146. * The panel will automatically compute the number of columns based on number of child controls.
  66147. */
  66148. rows: BABYLON.int;
  66149. /**
  66150. * Creates new VolumeBasedPanel
  66151. */
  66152. constructor();
  66153. protected _arrangeChildren(): void;
  66154. /** Child classes must implement this function to provide correct control positioning */
  66155. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66156. /** Child classes can implement this function to provide additional processing */
  66157. protected _finalProcessing(): void;
  66158. }
  66159. }
  66160. declare module BABYLON.GUI {
  66161. /**
  66162. * Class used to create a container panel deployed on the surface of a cylinder
  66163. */
  66164. export class CylinderPanel extends VolumeBasedPanel {
  66165. private _radius;
  66166. /**
  66167. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66168. */
  66169. radius: BABYLON.float;
  66170. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66171. private _cylindricalMapping;
  66172. }
  66173. }
  66174. declare module BABYLON.GUI {
  66175. /** @hidden */
  66176. export var fluentVertexShader: {
  66177. name: string;
  66178. shader: string;
  66179. };
  66180. }
  66181. declare module BABYLON.GUI {
  66182. /** @hidden */
  66183. export var fluentPixelShader: {
  66184. name: string;
  66185. shader: string;
  66186. };
  66187. }
  66188. declare module BABYLON.GUI {
  66189. /** @hidden */
  66190. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66191. INNERGLOW: boolean;
  66192. BORDER: boolean;
  66193. HOVERLIGHT: boolean;
  66194. TEXTURE: boolean;
  66195. constructor();
  66196. }
  66197. /**
  66198. * Class used to render controls with fluent desgin
  66199. */
  66200. export class FluentMaterial extends BABYLON.PushMaterial {
  66201. /**
  66202. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66203. */
  66204. innerGlowColorIntensity: number;
  66205. /**
  66206. * Gets or sets the inner glow color (white by default)
  66207. */
  66208. innerGlowColor: BABYLON.Color3;
  66209. /**
  66210. * Gets or sets alpha value (default is 1.0)
  66211. */
  66212. alpha: number;
  66213. /**
  66214. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66215. */
  66216. albedoColor: BABYLON.Color3;
  66217. /**
  66218. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66219. */
  66220. renderBorders: boolean;
  66221. /**
  66222. * Gets or sets border width (default is 0.5)
  66223. */
  66224. borderWidth: number;
  66225. /**
  66226. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66227. */
  66228. edgeSmoothingValue: number;
  66229. /**
  66230. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66231. */
  66232. borderMinValue: number;
  66233. /**
  66234. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66235. */
  66236. renderHoverLight: boolean;
  66237. /**
  66238. * Gets or sets the radius used to render the hover light (default is 1.0)
  66239. */
  66240. hoverRadius: number;
  66241. /**
  66242. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66243. */
  66244. hoverColor: BABYLON.Color4;
  66245. /**
  66246. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66247. */
  66248. hoverPosition: BABYLON.Vector3;
  66249. private _albedoTexture;
  66250. /** Gets or sets the texture to use for albedo color */
  66251. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66252. /**
  66253. * Creates a new Fluent material
  66254. * @param name defines the name of the material
  66255. * @param scene defines the hosting scene
  66256. */
  66257. constructor(name: string, scene: BABYLON.Scene);
  66258. needAlphaBlending(): boolean;
  66259. needAlphaTesting(): boolean;
  66260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66261. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66262. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66263. getActiveTextures(): BABYLON.BaseTexture[];
  66264. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66265. dispose(forceDisposeEffect?: boolean): void;
  66266. clone(name: string): FluentMaterial;
  66267. serialize(): any;
  66268. getClassName(): string;
  66269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66270. }
  66271. }
  66272. declare module BABYLON.GUI {
  66273. /**
  66274. * Class used to create a holographic button in 3D
  66275. */
  66276. export class HolographicButton extends Button3D {
  66277. private _backPlate;
  66278. private _textPlate;
  66279. private _frontPlate;
  66280. private _text;
  66281. private _imageUrl;
  66282. private _shareMaterials;
  66283. private _frontMaterial;
  66284. private _backMaterial;
  66285. private _plateMaterial;
  66286. private _pickedPointObserver;
  66287. private _tooltipFade;
  66288. private _tooltipTextBlock;
  66289. private _tooltipTexture;
  66290. private _tooltipMesh;
  66291. private _tooltipHoverObserver;
  66292. private _tooltipOutObserver;
  66293. private _disposeTooltip;
  66294. /**
  66295. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66296. */
  66297. tooltipText: BABYLON.Nullable<string>;
  66298. /**
  66299. * Gets or sets text for the button
  66300. */
  66301. text: string;
  66302. /**
  66303. * Gets or sets the image url for the button
  66304. */
  66305. imageUrl: string;
  66306. /**
  66307. * Gets the back material used by this button
  66308. */
  66309. readonly backMaterial: FluentMaterial;
  66310. /**
  66311. * Gets the front material used by this button
  66312. */
  66313. readonly frontMaterial: FluentMaterial;
  66314. /**
  66315. * Gets the plate material used by this button
  66316. */
  66317. readonly plateMaterial: BABYLON.StandardMaterial;
  66318. /**
  66319. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66320. */
  66321. readonly shareMaterials: boolean;
  66322. /**
  66323. * Creates a new button
  66324. * @param name defines the control name
  66325. */
  66326. constructor(name?: string, shareMaterials?: boolean);
  66327. protected _getTypeName(): string;
  66328. private _rebuildContent;
  66329. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66330. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66331. private _createBackMaterial;
  66332. private _createFrontMaterial;
  66333. private _createPlateMaterial;
  66334. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66335. /**
  66336. * Releases all associated resources
  66337. */
  66338. dispose(): void;
  66339. }
  66340. }
  66341. declare module BABYLON.GUI {
  66342. /**
  66343. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66344. */
  66345. export class MeshButton3D extends Button3D {
  66346. /** @hidden */
  66347. protected _currentMesh: BABYLON.Mesh;
  66348. /**
  66349. * Creates a new 3D button based on a mesh
  66350. * @param mesh mesh to become a 3D button
  66351. * @param name defines the control name
  66352. */
  66353. constructor(mesh: BABYLON.Mesh, name?: string);
  66354. protected _getTypeName(): string;
  66355. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66356. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66357. }
  66358. }
  66359. declare module BABYLON.GUI {
  66360. /**
  66361. * Class used to create a container panel deployed on the surface of a plane
  66362. */
  66363. export class PlanePanel extends VolumeBasedPanel {
  66364. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66365. }
  66366. }
  66367. declare module BABYLON.GUI {
  66368. /**
  66369. * Class used to create a container panel where items get randomized planar mapping
  66370. */
  66371. export class ScatterPanel extends VolumeBasedPanel {
  66372. private _iteration;
  66373. /**
  66374. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66375. */
  66376. iteration: BABYLON.float;
  66377. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66378. private _scatterMapping;
  66379. protected _finalProcessing(): void;
  66380. }
  66381. }
  66382. declare module BABYLON.GUI {
  66383. /**
  66384. * Class used to create a container panel deployed on the surface of a sphere
  66385. */
  66386. export class SpherePanel extends VolumeBasedPanel {
  66387. private _radius;
  66388. /**
  66389. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66390. */
  66391. radius: BABYLON.float;
  66392. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66393. private _sphericalMapping;
  66394. }
  66395. }
  66396. declare module BABYLON.GUI {
  66397. /**
  66398. * Class used to create a stack panel in 3D on XY plane
  66399. */
  66400. export class StackPanel3D extends Container3D {
  66401. private _isVertical;
  66402. /**
  66403. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66404. */
  66405. isVertical: boolean;
  66406. /**
  66407. * Gets or sets the distance between elements
  66408. */
  66409. margin: number;
  66410. /**
  66411. * Creates new StackPanel
  66412. * @param isVertical
  66413. */
  66414. constructor(isVertical?: boolean);
  66415. protected _arrangeChildren(): void;
  66416. }
  66417. }
  66418. declare module BABYLON {
  66419. /**
  66420. * Mode that determines the coordinate system to use.
  66421. */
  66422. export enum GLTFLoaderCoordinateSystemMode {
  66423. /**
  66424. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66425. */
  66426. AUTO = 0,
  66427. /**
  66428. * Sets the useRightHandedSystem flag on the scene.
  66429. */
  66430. FORCE_RIGHT_HANDED = 1
  66431. }
  66432. /**
  66433. * Mode that determines what animations will start.
  66434. */
  66435. export enum GLTFLoaderAnimationStartMode {
  66436. /**
  66437. * No animation will start.
  66438. */
  66439. NONE = 0,
  66440. /**
  66441. * The first animation will start.
  66442. */
  66443. FIRST = 1,
  66444. /**
  66445. * All animations will start.
  66446. */
  66447. ALL = 2
  66448. }
  66449. /**
  66450. * Interface that contains the data for the glTF asset.
  66451. */
  66452. export interface IGLTFLoaderData {
  66453. /**
  66454. * Object that represents the glTF JSON.
  66455. */
  66456. json: Object;
  66457. /**
  66458. * The BIN chunk of a binary glTF.
  66459. */
  66460. bin: Nullable<ArrayBufferView>;
  66461. }
  66462. /**
  66463. * Interface for extending the loader.
  66464. */
  66465. export interface IGLTFLoaderExtension {
  66466. /**
  66467. * The name of this extension.
  66468. */
  66469. readonly name: string;
  66470. /**
  66471. * Defines whether this extension is enabled.
  66472. */
  66473. enabled: boolean;
  66474. }
  66475. /**
  66476. * Loader state.
  66477. */
  66478. export enum GLTFLoaderState {
  66479. /**
  66480. * The asset is loading.
  66481. */
  66482. LOADING = 0,
  66483. /**
  66484. * The asset is ready for rendering.
  66485. */
  66486. READY = 1,
  66487. /**
  66488. * The asset is completely loaded.
  66489. */
  66490. COMPLETE = 2
  66491. }
  66492. /** @hidden */
  66493. export interface IGLTFLoader extends IDisposable {
  66494. readonly state: Nullable<GLTFLoaderState>;
  66495. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66496. meshes: AbstractMesh[];
  66497. particleSystems: IParticleSystem[];
  66498. skeletons: Skeleton[];
  66499. animationGroups: AnimationGroup[];
  66500. }>;
  66501. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66502. }
  66503. /**
  66504. * File loader for loading glTF files into a scene.
  66505. */
  66506. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66507. /** @hidden */
  66508. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66509. /** @hidden */
  66510. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66511. /**
  66512. * Raised when the asset has been parsed
  66513. */
  66514. onParsedObservable: Observable<IGLTFLoaderData>;
  66515. private _onParsedObserver;
  66516. /**
  66517. * Raised when the asset has been parsed
  66518. */
  66519. onParsed: (loaderData: IGLTFLoaderData) => void;
  66520. /**
  66521. * 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.
  66522. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66523. * Defaults to true.
  66524. * @hidden
  66525. */
  66526. static IncrementalLoading: boolean;
  66527. /**
  66528. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66529. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66530. * @hidden
  66531. */
  66532. static HomogeneousCoordinates: boolean;
  66533. /**
  66534. * The coordinate system mode. Defaults to AUTO.
  66535. */
  66536. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66537. /**
  66538. * The animation start mode. Defaults to FIRST.
  66539. */
  66540. animationStartMode: GLTFLoaderAnimationStartMode;
  66541. /**
  66542. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66543. */
  66544. compileMaterials: boolean;
  66545. /**
  66546. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66547. */
  66548. useClipPlane: boolean;
  66549. /**
  66550. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66551. */
  66552. compileShadowGenerators: boolean;
  66553. /**
  66554. * Defines if the Alpha blended materials are only applied as coverage.
  66555. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66556. * If true, no extra effects are applied to transparent pixels.
  66557. */
  66558. transparencyAsCoverage: boolean;
  66559. /**
  66560. * Function called before loading a url referenced by the asset.
  66561. */
  66562. preprocessUrlAsync: (url: string) => Promise<string>;
  66563. /**
  66564. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66565. */
  66566. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66567. private _onMeshLoadedObserver;
  66568. /**
  66569. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66570. */
  66571. onMeshLoaded: (mesh: AbstractMesh) => void;
  66572. /**
  66573. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66574. */
  66575. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66576. private _onTextureLoadedObserver;
  66577. /**
  66578. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66579. */
  66580. onTextureLoaded: (texture: BaseTexture) => void;
  66581. /**
  66582. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66583. */
  66584. readonly onMaterialLoadedObservable: Observable<Material>;
  66585. private _onMaterialLoadedObserver;
  66586. /**
  66587. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66588. */
  66589. onMaterialLoaded: (material: Material) => void;
  66590. /**
  66591. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66592. */
  66593. readonly onCameraLoadedObservable: Observable<Camera>;
  66594. private _onCameraLoadedObserver;
  66595. /**
  66596. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66597. */
  66598. onCameraLoaded: (camera: Camera) => void;
  66599. /**
  66600. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66601. * For assets with LODs, raised when all of the LODs are complete.
  66602. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66603. */
  66604. readonly onCompleteObservable: Observable<void>;
  66605. private _onCompleteObserver;
  66606. /**
  66607. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66608. * For assets with LODs, raised when all of the LODs are complete.
  66609. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66610. */
  66611. onComplete: () => void;
  66612. /**
  66613. * Observable raised when an error occurs.
  66614. */
  66615. readonly onErrorObservable: Observable<any>;
  66616. private _onErrorObserver;
  66617. /**
  66618. * Callback raised when an error occurs.
  66619. */
  66620. onError: (reason: any) => void;
  66621. /**
  66622. * Observable raised after the loader is disposed.
  66623. */
  66624. readonly onDisposeObservable: Observable<void>;
  66625. private _onDisposeObserver;
  66626. /**
  66627. * Callback raised after the loader is disposed.
  66628. */
  66629. onDispose: () => void;
  66630. /**
  66631. * Observable raised after a loader extension is created.
  66632. * Set additional options for a loader extension in this event.
  66633. */
  66634. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66635. private _onExtensionLoadedObserver;
  66636. /**
  66637. * Callback raised after a loader extension is created.
  66638. */
  66639. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66640. /**
  66641. * Defines if the loader logging is enabled.
  66642. */
  66643. loggingEnabled: boolean;
  66644. /**
  66645. * Defines if the loader should capture performance counters.
  66646. */
  66647. capturePerformanceCounters: boolean;
  66648. /**
  66649. * Defines if the loader should validate the asset.
  66650. */
  66651. validate: boolean;
  66652. /**
  66653. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66654. */
  66655. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66656. private _onValidatedObserver;
  66657. /**
  66658. * Callback raised after a loader extension is created.
  66659. */
  66660. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66661. private _loader;
  66662. /**
  66663. * Name of the loader ("gltf")
  66664. */
  66665. name: string;
  66666. /**
  66667. * Supported file extensions of the loader (.gltf, .glb)
  66668. */
  66669. extensions: ISceneLoaderPluginExtensions;
  66670. /**
  66671. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66672. */
  66673. dispose(): void;
  66674. /** @hidden */
  66675. _clear(): void;
  66676. /**
  66677. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66678. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66679. * @param scene the scene the meshes should be added to
  66680. * @param data the glTF data to load
  66681. * @param rootUrl root url to load from
  66682. * @param onProgress event that fires when loading progress has occured
  66683. * @param fileName Defines the name of the file to load
  66684. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66685. */
  66686. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66687. meshes: AbstractMesh[];
  66688. particleSystems: IParticleSystem[];
  66689. skeletons: Skeleton[];
  66690. animationGroups: AnimationGroup[];
  66691. }>;
  66692. /**
  66693. * Imports all objects from the loaded glTF data and adds them to the scene
  66694. * @param scene the scene the objects should be added to
  66695. * @param data the glTF data to load
  66696. * @param rootUrl root url to load from
  66697. * @param onProgress event that fires when loading progress has occured
  66698. * @param fileName Defines the name of the file to load
  66699. * @returns a promise which completes when objects have been loaded to the scene
  66700. */
  66701. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66702. /**
  66703. * Load into an asset container.
  66704. * @param scene The scene to load into
  66705. * @param data The data to import
  66706. * @param rootUrl The root url for scene and resources
  66707. * @param onProgress The callback when the load progresses
  66708. * @param fileName Defines the name of the file to load
  66709. * @returns The loaded asset container
  66710. */
  66711. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66712. /**
  66713. * If the data string can be loaded directly.
  66714. * @param data string contianing the file data
  66715. * @returns if the data can be loaded directly
  66716. */
  66717. canDirectLoad(data: string): boolean;
  66718. /**
  66719. * Rewrites a url by combining a root url and response url.
  66720. */
  66721. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66722. /**
  66723. * Instantiates a glTF file loader plugin.
  66724. * @returns the created plugin
  66725. */
  66726. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66727. /**
  66728. * The loader state or null if the loader is not active.
  66729. */
  66730. readonly loaderState: Nullable<GLTFLoaderState>;
  66731. /**
  66732. * Returns a promise that resolves when the asset is completely loaded.
  66733. * @returns a promise that resolves when the asset is completely loaded.
  66734. */
  66735. whenCompleteAsync(): Promise<void>;
  66736. private _parseAsync;
  66737. private _validateAsync;
  66738. private _getLoader;
  66739. private _unpackBinary;
  66740. private _unpackBinaryV1;
  66741. private _unpackBinaryV2;
  66742. private static _parseVersion;
  66743. private static _compareVersion;
  66744. private static _decodeBufferToText;
  66745. private static readonly _logSpaces;
  66746. private _logIndentLevel;
  66747. private _loggingEnabled;
  66748. /** @hidden */
  66749. _log: (message: string) => void;
  66750. /** @hidden */
  66751. _logOpen(message: string): void;
  66752. /** @hidden */
  66753. _logClose(): void;
  66754. private _logEnabled;
  66755. private _logDisabled;
  66756. private _capturePerformanceCounters;
  66757. /** @hidden */
  66758. _startPerformanceCounter: (counterName: string) => void;
  66759. /** @hidden */
  66760. _endPerformanceCounter: (counterName: string) => void;
  66761. private _startPerformanceCounterEnabled;
  66762. private _startPerformanceCounterDisabled;
  66763. private _endPerformanceCounterEnabled;
  66764. private _endPerformanceCounterDisabled;
  66765. }
  66766. }
  66767. declare module BABYLON.GLTF1 {
  66768. /**
  66769. * Enums
  66770. * @hidden
  66771. */
  66772. export enum EComponentType {
  66773. BYTE = 5120,
  66774. UNSIGNED_BYTE = 5121,
  66775. SHORT = 5122,
  66776. UNSIGNED_SHORT = 5123,
  66777. FLOAT = 5126
  66778. }
  66779. /** @hidden */
  66780. export enum EShaderType {
  66781. FRAGMENT = 35632,
  66782. VERTEX = 35633
  66783. }
  66784. /** @hidden */
  66785. export enum EParameterType {
  66786. BYTE = 5120,
  66787. UNSIGNED_BYTE = 5121,
  66788. SHORT = 5122,
  66789. UNSIGNED_SHORT = 5123,
  66790. INT = 5124,
  66791. UNSIGNED_INT = 5125,
  66792. FLOAT = 5126,
  66793. FLOAT_VEC2 = 35664,
  66794. FLOAT_VEC3 = 35665,
  66795. FLOAT_VEC4 = 35666,
  66796. INT_VEC2 = 35667,
  66797. INT_VEC3 = 35668,
  66798. INT_VEC4 = 35669,
  66799. BOOL = 35670,
  66800. BOOL_VEC2 = 35671,
  66801. BOOL_VEC3 = 35672,
  66802. BOOL_VEC4 = 35673,
  66803. FLOAT_MAT2 = 35674,
  66804. FLOAT_MAT3 = 35675,
  66805. FLOAT_MAT4 = 35676,
  66806. SAMPLER_2D = 35678
  66807. }
  66808. /** @hidden */
  66809. export enum ETextureWrapMode {
  66810. CLAMP_TO_EDGE = 33071,
  66811. MIRRORED_REPEAT = 33648,
  66812. REPEAT = 10497
  66813. }
  66814. /** @hidden */
  66815. export enum ETextureFilterType {
  66816. NEAREST = 9728,
  66817. LINEAR = 9728,
  66818. NEAREST_MIPMAP_NEAREST = 9984,
  66819. LINEAR_MIPMAP_NEAREST = 9985,
  66820. NEAREST_MIPMAP_LINEAR = 9986,
  66821. LINEAR_MIPMAP_LINEAR = 9987
  66822. }
  66823. /** @hidden */
  66824. export enum ETextureFormat {
  66825. ALPHA = 6406,
  66826. RGB = 6407,
  66827. RGBA = 6408,
  66828. LUMINANCE = 6409,
  66829. LUMINANCE_ALPHA = 6410
  66830. }
  66831. /** @hidden */
  66832. export enum ECullingType {
  66833. FRONT = 1028,
  66834. BACK = 1029,
  66835. FRONT_AND_BACK = 1032
  66836. }
  66837. /** @hidden */
  66838. export enum EBlendingFunction {
  66839. ZERO = 0,
  66840. ONE = 1,
  66841. SRC_COLOR = 768,
  66842. ONE_MINUS_SRC_COLOR = 769,
  66843. DST_COLOR = 774,
  66844. ONE_MINUS_DST_COLOR = 775,
  66845. SRC_ALPHA = 770,
  66846. ONE_MINUS_SRC_ALPHA = 771,
  66847. DST_ALPHA = 772,
  66848. ONE_MINUS_DST_ALPHA = 773,
  66849. CONSTANT_COLOR = 32769,
  66850. ONE_MINUS_CONSTANT_COLOR = 32770,
  66851. CONSTANT_ALPHA = 32771,
  66852. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66853. SRC_ALPHA_SATURATE = 776
  66854. }
  66855. /** @hidden */
  66856. export interface IGLTFProperty {
  66857. extensions?: {
  66858. [key: string]: any;
  66859. };
  66860. extras?: Object;
  66861. }
  66862. /** @hidden */
  66863. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66864. name?: string;
  66865. }
  66866. /** @hidden */
  66867. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66868. bufferView: string;
  66869. byteOffset: number;
  66870. byteStride: number;
  66871. count: number;
  66872. type: string;
  66873. componentType: EComponentType;
  66874. max?: number[];
  66875. min?: number[];
  66876. name?: string;
  66877. }
  66878. /** @hidden */
  66879. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66880. buffer: string;
  66881. byteOffset: number;
  66882. byteLength: number;
  66883. byteStride: number;
  66884. target?: number;
  66885. }
  66886. /** @hidden */
  66887. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66888. uri: string;
  66889. byteLength?: number;
  66890. type?: string;
  66891. }
  66892. /** @hidden */
  66893. export interface IGLTFShader extends IGLTFChildRootProperty {
  66894. uri: string;
  66895. type: EShaderType;
  66896. }
  66897. /** @hidden */
  66898. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66899. attributes: string[];
  66900. fragmentShader: string;
  66901. vertexShader: string;
  66902. }
  66903. /** @hidden */
  66904. export interface IGLTFTechniqueParameter {
  66905. type: number;
  66906. count?: number;
  66907. semantic?: string;
  66908. node?: string;
  66909. value?: number | boolean | string | Array<any>;
  66910. source?: string;
  66911. babylonValue?: any;
  66912. }
  66913. /** @hidden */
  66914. export interface IGLTFTechniqueCommonProfile {
  66915. lightingModel: string;
  66916. texcoordBindings: Object;
  66917. parameters?: Array<any>;
  66918. }
  66919. /** @hidden */
  66920. export interface IGLTFTechniqueStatesFunctions {
  66921. blendColor?: number[];
  66922. blendEquationSeparate?: number[];
  66923. blendFuncSeparate?: number[];
  66924. colorMask: boolean[];
  66925. cullFace: number[];
  66926. }
  66927. /** @hidden */
  66928. export interface IGLTFTechniqueStates {
  66929. enable: number[];
  66930. functions: IGLTFTechniqueStatesFunctions;
  66931. }
  66932. /** @hidden */
  66933. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66934. parameters: {
  66935. [key: string]: IGLTFTechniqueParameter;
  66936. };
  66937. program: string;
  66938. attributes: {
  66939. [key: string]: string;
  66940. };
  66941. uniforms: {
  66942. [key: string]: string;
  66943. };
  66944. states: IGLTFTechniqueStates;
  66945. }
  66946. /** @hidden */
  66947. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66948. technique?: string;
  66949. values: string[];
  66950. }
  66951. /** @hidden */
  66952. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66953. attributes: {
  66954. [key: string]: string;
  66955. };
  66956. indices: string;
  66957. material: string;
  66958. mode?: number;
  66959. }
  66960. /** @hidden */
  66961. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66962. primitives: IGLTFMeshPrimitive[];
  66963. }
  66964. /** @hidden */
  66965. export interface IGLTFImage extends IGLTFChildRootProperty {
  66966. uri: string;
  66967. }
  66968. /** @hidden */
  66969. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66970. magFilter?: number;
  66971. minFilter?: number;
  66972. wrapS?: number;
  66973. wrapT?: number;
  66974. }
  66975. /** @hidden */
  66976. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66977. sampler: string;
  66978. source: string;
  66979. format?: ETextureFormat;
  66980. internalFormat?: ETextureFormat;
  66981. target?: number;
  66982. type?: number;
  66983. babylonTexture?: Texture;
  66984. }
  66985. /** @hidden */
  66986. export interface IGLTFAmbienLight {
  66987. color?: number[];
  66988. }
  66989. /** @hidden */
  66990. export interface IGLTFDirectionalLight {
  66991. color?: number[];
  66992. }
  66993. /** @hidden */
  66994. export interface IGLTFPointLight {
  66995. color?: number[];
  66996. constantAttenuation?: number;
  66997. linearAttenuation?: number;
  66998. quadraticAttenuation?: number;
  66999. }
  67000. /** @hidden */
  67001. export interface IGLTFSpotLight {
  67002. color?: number[];
  67003. constantAttenuation?: number;
  67004. fallOfAngle?: number;
  67005. fallOffExponent?: number;
  67006. linearAttenuation?: number;
  67007. quadraticAttenuation?: number;
  67008. }
  67009. /** @hidden */
  67010. export interface IGLTFLight extends IGLTFChildRootProperty {
  67011. type: string;
  67012. }
  67013. /** @hidden */
  67014. export interface IGLTFCameraOrthographic {
  67015. xmag: number;
  67016. ymag: number;
  67017. zfar: number;
  67018. znear: number;
  67019. }
  67020. /** @hidden */
  67021. export interface IGLTFCameraPerspective {
  67022. aspectRatio: number;
  67023. yfov: number;
  67024. zfar: number;
  67025. znear: number;
  67026. }
  67027. /** @hidden */
  67028. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67029. type: string;
  67030. }
  67031. /** @hidden */
  67032. export interface IGLTFAnimationChannelTarget {
  67033. id: string;
  67034. path: string;
  67035. }
  67036. /** @hidden */
  67037. export interface IGLTFAnimationChannel {
  67038. sampler: string;
  67039. target: IGLTFAnimationChannelTarget;
  67040. }
  67041. /** @hidden */
  67042. export interface IGLTFAnimationSampler {
  67043. input: string;
  67044. output: string;
  67045. interpolation?: string;
  67046. }
  67047. /** @hidden */
  67048. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67049. channels?: IGLTFAnimationChannel[];
  67050. parameters?: {
  67051. [key: string]: string;
  67052. };
  67053. samplers?: {
  67054. [key: string]: IGLTFAnimationSampler;
  67055. };
  67056. }
  67057. /** @hidden */
  67058. export interface IGLTFNodeInstanceSkin {
  67059. skeletons: string[];
  67060. skin: string;
  67061. meshes: string[];
  67062. }
  67063. /** @hidden */
  67064. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67065. bindShapeMatrix: number[];
  67066. inverseBindMatrices: string;
  67067. jointNames: string[];
  67068. babylonSkeleton?: Skeleton;
  67069. }
  67070. /** @hidden */
  67071. export interface IGLTFNode extends IGLTFChildRootProperty {
  67072. camera?: string;
  67073. children: string[];
  67074. skin?: string;
  67075. jointName?: string;
  67076. light?: string;
  67077. matrix: number[];
  67078. mesh?: string;
  67079. meshes?: string[];
  67080. rotation?: number[];
  67081. scale?: number[];
  67082. translation?: number[];
  67083. babylonNode?: Node;
  67084. }
  67085. /** @hidden */
  67086. export interface IGLTFScene extends IGLTFChildRootProperty {
  67087. nodes: string[];
  67088. }
  67089. /** @hidden */
  67090. export interface IGLTFRuntime {
  67091. extensions: {
  67092. [key: string]: any;
  67093. };
  67094. accessors: {
  67095. [key: string]: IGLTFAccessor;
  67096. };
  67097. buffers: {
  67098. [key: string]: IGLTFBuffer;
  67099. };
  67100. bufferViews: {
  67101. [key: string]: IGLTFBufferView;
  67102. };
  67103. meshes: {
  67104. [key: string]: IGLTFMesh;
  67105. };
  67106. lights: {
  67107. [key: string]: IGLTFLight;
  67108. };
  67109. cameras: {
  67110. [key: string]: IGLTFCamera;
  67111. };
  67112. nodes: {
  67113. [key: string]: IGLTFNode;
  67114. };
  67115. images: {
  67116. [key: string]: IGLTFImage;
  67117. };
  67118. textures: {
  67119. [key: string]: IGLTFTexture;
  67120. };
  67121. shaders: {
  67122. [key: string]: IGLTFShader;
  67123. };
  67124. programs: {
  67125. [key: string]: IGLTFProgram;
  67126. };
  67127. samplers: {
  67128. [key: string]: IGLTFSampler;
  67129. };
  67130. techniques: {
  67131. [key: string]: IGLTFTechnique;
  67132. };
  67133. materials: {
  67134. [key: string]: IGLTFMaterial;
  67135. };
  67136. animations: {
  67137. [key: string]: IGLTFAnimation;
  67138. };
  67139. skins: {
  67140. [key: string]: IGLTFSkins;
  67141. };
  67142. currentScene?: Object;
  67143. scenes: {
  67144. [key: string]: IGLTFScene;
  67145. };
  67146. extensionsUsed: string[];
  67147. extensionsRequired?: string[];
  67148. buffersCount: number;
  67149. shaderscount: number;
  67150. scene: Scene;
  67151. rootUrl: string;
  67152. loadedBufferCount: number;
  67153. loadedBufferViews: {
  67154. [name: string]: ArrayBufferView;
  67155. };
  67156. loadedShaderCount: number;
  67157. importOnlyMeshes: boolean;
  67158. importMeshesNames?: string[];
  67159. dummyNodes: Node[];
  67160. }
  67161. /** @hidden */
  67162. export interface INodeToRoot {
  67163. bone: Bone;
  67164. node: IGLTFNode;
  67165. id: string;
  67166. }
  67167. /** @hidden */
  67168. export interface IJointNode {
  67169. node: IGLTFNode;
  67170. id: string;
  67171. }
  67172. }
  67173. declare module BABYLON.GLTF1 {
  67174. /**
  67175. * Utils functions for GLTF
  67176. * @hidden
  67177. */
  67178. export class GLTFUtils {
  67179. /**
  67180. * Sets the given "parameter" matrix
  67181. * @param scene: the Scene object
  67182. * @param source: the source node where to pick the matrix
  67183. * @param parameter: the GLTF technique parameter
  67184. * @param uniformName: the name of the shader's uniform
  67185. * @param shaderMaterial: the shader material
  67186. */
  67187. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67188. /**
  67189. * Sets the given "parameter" matrix
  67190. * @param shaderMaterial: the shader material
  67191. * @param uniform: the name of the shader's uniform
  67192. * @param value: the value of the uniform
  67193. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67194. */
  67195. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67196. /**
  67197. * Returns the wrap mode of the texture
  67198. * @param mode: the mode value
  67199. */
  67200. static GetWrapMode(mode: number): number;
  67201. /**
  67202. * Returns the byte stride giving an accessor
  67203. * @param accessor: the GLTF accessor objet
  67204. */
  67205. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67206. /**
  67207. * Returns the texture filter mode giving a mode value
  67208. * @param mode: the filter mode value
  67209. */
  67210. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67211. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67212. /**
  67213. * Returns a buffer from its accessor
  67214. * @param gltfRuntime: the GLTF runtime
  67215. * @param accessor: the GLTF accessor
  67216. */
  67217. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67218. /**
  67219. * Decodes a buffer view into a string
  67220. * @param view: the buffer view
  67221. */
  67222. static DecodeBufferToText(view: ArrayBufferView): string;
  67223. /**
  67224. * Returns the default material of gltf. Related to
  67225. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67226. * @param scene: the Babylon.js scene
  67227. */
  67228. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67229. private static _DefaultMaterial;
  67230. }
  67231. }
  67232. declare module BABYLON.GLTF1 {
  67233. /**
  67234. * Implementation of the base glTF spec
  67235. * @hidden
  67236. */
  67237. export class GLTFLoaderBase {
  67238. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67239. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67240. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67241. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67242. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67243. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67244. }
  67245. /**
  67246. * glTF V1 Loader
  67247. * @hidden
  67248. */
  67249. export class GLTFLoader implements IGLTFLoader {
  67250. static Extensions: {
  67251. [name: string]: GLTFLoaderExtension;
  67252. };
  67253. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67254. state: Nullable<GLTFLoaderState>;
  67255. dispose(): void;
  67256. private _importMeshAsync;
  67257. /**
  67258. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67259. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67260. * @param scene the scene the meshes should be added to
  67261. * @param data gltf data containing information of the meshes in a loaded file
  67262. * @param rootUrl root url to load from
  67263. * @param onProgress event that fires when loading progress has occured
  67264. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67265. */
  67266. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67267. meshes: AbstractMesh[];
  67268. particleSystems: IParticleSystem[];
  67269. skeletons: Skeleton[];
  67270. animationGroups: AnimationGroup[];
  67271. }>;
  67272. private _loadAsync;
  67273. /**
  67274. * Imports all objects from a loaded gltf file and adds them to the scene
  67275. * @param scene the scene the objects should be added to
  67276. * @param data gltf data containing information of the meshes in a loaded file
  67277. * @param rootUrl root url to load from
  67278. * @param onProgress event that fires when loading progress has occured
  67279. * @returns a promise which completes when objects have been loaded to the scene
  67280. */
  67281. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67282. private _loadShadersAsync;
  67283. private _loadBuffersAsync;
  67284. private _createNodes;
  67285. }
  67286. /** @hidden */
  67287. export abstract class GLTFLoaderExtension {
  67288. private _name;
  67289. constructor(name: string);
  67290. readonly name: string;
  67291. /**
  67292. * Defines an override for loading the runtime
  67293. * Return true to stop further extensions from loading the runtime
  67294. */
  67295. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67296. /**
  67297. * Defines an onverride for creating gltf runtime
  67298. * Return true to stop further extensions from creating the runtime
  67299. */
  67300. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67301. /**
  67302. * Defines an override for loading buffers
  67303. * Return true to stop further extensions from loading this buffer
  67304. */
  67305. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67306. /**
  67307. * Defines an override for loading texture buffers
  67308. * Return true to stop further extensions from loading this texture data
  67309. */
  67310. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67311. /**
  67312. * Defines an override for creating textures
  67313. * Return true to stop further extensions from loading this texture
  67314. */
  67315. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67316. /**
  67317. * Defines an override for loading shader strings
  67318. * Return true to stop further extensions from loading this shader data
  67319. */
  67320. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67321. /**
  67322. * Defines an override for loading materials
  67323. * Return true to stop further extensions from loading this material
  67324. */
  67325. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67326. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67327. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67328. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67329. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67330. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67331. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67332. private static LoadTextureBufferAsync;
  67333. private static CreateTextureAsync;
  67334. private static ApplyExtensions;
  67335. }
  67336. }
  67337. declare module BABYLON.GLTF1 {
  67338. /** @hidden */
  67339. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67340. private _bin;
  67341. constructor();
  67342. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67343. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67344. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67345. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67346. }
  67347. }
  67348. declare module BABYLON.GLTF1 {
  67349. /** @hidden */
  67350. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67351. constructor();
  67352. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67353. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67354. private _loadTexture;
  67355. }
  67356. }
  67357. declare module BABYLON.GLTF2.Loader {
  67358. /**
  67359. * Loader interface with an index field.
  67360. */
  67361. export interface IArrayItem {
  67362. /**
  67363. * The index of this item in the array.
  67364. */
  67365. index: number;
  67366. }
  67367. /**
  67368. * Loader interface with additional members.
  67369. */
  67370. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67371. /** @hidden */
  67372. _data?: Promise<ArrayBufferView>;
  67373. /** @hidden */
  67374. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67375. }
  67376. /**
  67377. * Loader interface with additional members.
  67378. */
  67379. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67380. }
  67381. /** @hidden */
  67382. export interface _IAnimationSamplerData {
  67383. input: Float32Array;
  67384. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67385. output: Float32Array;
  67386. }
  67387. /**
  67388. * Loader interface with additional members.
  67389. */
  67390. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67391. /** @hidden */
  67392. _data?: Promise<_IAnimationSamplerData>;
  67393. }
  67394. /**
  67395. * Loader interface with additional members.
  67396. */
  67397. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67398. channels: IAnimationChannel[];
  67399. samplers: IAnimationSampler[];
  67400. /** @hidden */
  67401. _babylonAnimationGroup?: AnimationGroup;
  67402. }
  67403. /**
  67404. * Loader interface with additional members.
  67405. */
  67406. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67407. /** @hidden */
  67408. _data?: Promise<ArrayBufferView>;
  67409. }
  67410. /**
  67411. * Loader interface with additional members.
  67412. */
  67413. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67414. /** @hidden */
  67415. _data?: Promise<ArrayBufferView>;
  67416. /** @hidden */
  67417. _babylonBuffer?: Promise<Buffer>;
  67418. }
  67419. /**
  67420. * Loader interface with additional members.
  67421. */
  67422. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67423. }
  67424. /**
  67425. * Loader interface with additional members.
  67426. */
  67427. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67428. /** @hidden */
  67429. _data?: Promise<ArrayBufferView>;
  67430. }
  67431. /**
  67432. * Loader interface with additional members.
  67433. */
  67434. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67435. }
  67436. /**
  67437. * Loader interface with additional members.
  67438. */
  67439. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67440. }
  67441. /**
  67442. * Loader interface with additional members.
  67443. */
  67444. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67445. baseColorTexture?: ITextureInfo;
  67446. metallicRoughnessTexture?: ITextureInfo;
  67447. }
  67448. /**
  67449. * Loader interface with additional members.
  67450. */
  67451. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67452. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67453. normalTexture?: IMaterialNormalTextureInfo;
  67454. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67455. emissiveTexture?: ITextureInfo;
  67456. /** @hidden */
  67457. _data?: {
  67458. [babylonDrawMode: number]: {
  67459. babylonMaterial: Material;
  67460. babylonMeshes: AbstractMesh[];
  67461. promise: Promise<void>;
  67462. };
  67463. };
  67464. }
  67465. /**
  67466. * Loader interface with additional members.
  67467. */
  67468. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67469. primitives: IMeshPrimitive[];
  67470. }
  67471. /**
  67472. * Loader interface with additional members.
  67473. */
  67474. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67475. /** @hidden */
  67476. _instanceData?: {
  67477. babylonSourceMesh: Mesh;
  67478. promise: Promise<any>;
  67479. };
  67480. }
  67481. /**
  67482. * Loader interface with additional members.
  67483. */
  67484. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67485. /**
  67486. * The parent glTF node.
  67487. */
  67488. parent?: INode;
  67489. /** @hidden */
  67490. _babylonTransformNode?: TransformNode;
  67491. /** @hidden */
  67492. _primitiveBabylonMeshes?: AbstractMesh[];
  67493. /** @hidden */
  67494. _babylonBones?: Bone[];
  67495. /** @hidden */
  67496. _numMorphTargets?: number;
  67497. }
  67498. /** @hidden */
  67499. export interface _ISamplerData {
  67500. noMipMaps: boolean;
  67501. samplingMode: number;
  67502. wrapU: number;
  67503. wrapV: number;
  67504. }
  67505. /**
  67506. * Loader interface with additional members.
  67507. */
  67508. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67509. /** @hidden */
  67510. _data?: _ISamplerData;
  67511. }
  67512. /**
  67513. * Loader interface with additional members.
  67514. */
  67515. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67516. }
  67517. /**
  67518. * Loader interface with additional members.
  67519. */
  67520. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67521. /** @hidden */
  67522. _data?: {
  67523. babylonSkeleton: Skeleton;
  67524. promise: Promise<void>;
  67525. };
  67526. }
  67527. /**
  67528. * Loader interface with additional members.
  67529. */
  67530. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67531. }
  67532. /**
  67533. * Loader interface with additional members.
  67534. */
  67535. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67536. }
  67537. /**
  67538. * Loader interface with additional members.
  67539. */
  67540. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67541. accessors?: IAccessor[];
  67542. animations?: IAnimation[];
  67543. buffers?: IBuffer[];
  67544. bufferViews?: IBufferView[];
  67545. cameras?: ICamera[];
  67546. images?: IImage[];
  67547. materials?: IMaterial[];
  67548. meshes?: IMesh[];
  67549. nodes?: INode[];
  67550. samplers?: ISampler[];
  67551. scenes?: IScene[];
  67552. skins?: ISkin[];
  67553. textures?: ITexture[];
  67554. }
  67555. }
  67556. declare module BABYLON.GLTF2 {
  67557. /**
  67558. * Interface for a glTF loader extension.
  67559. */
  67560. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67561. /**
  67562. * Called after the loader state changes to LOADING.
  67563. */
  67564. onLoading?(): void;
  67565. /**
  67566. * Called after the loader state changes to READY.
  67567. */
  67568. onReady?(): void;
  67569. /**
  67570. * Define this method to modify the default behavior when loading scenes.
  67571. * @param context The context when loading the asset
  67572. * @param scene The glTF scene property
  67573. * @returns A promise that resolves when the load is complete or null if not handled
  67574. */
  67575. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67576. /**
  67577. * Define this method to modify the default behavior when loading nodes.
  67578. * @param context The context when loading the asset
  67579. * @param node The glTF node property
  67580. * @param assign A function called synchronously after parsing the glTF properties
  67581. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67582. */
  67583. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67584. /**
  67585. * Define this method to modify the default behavior when loading cameras.
  67586. * @param context The context when loading the asset
  67587. * @param camera The glTF camera property
  67588. * @param assign A function called synchronously after parsing the glTF properties
  67589. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67590. */
  67591. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67592. /**
  67593. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67594. * @param context The context when loading the asset
  67595. * @param primitive The glTF mesh primitive property
  67596. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67597. */
  67598. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67599. /**
  67600. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67601. * @param context The context when loading the asset
  67602. * @param name The mesh name when loading the asset
  67603. * @param node The glTF node when loading the asset
  67604. * @param mesh The glTF mesh when loading the asset
  67605. * @param primitive The glTF mesh primitive property
  67606. * @param assign A function called synchronously after parsing the glTF properties
  67607. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67608. */
  67609. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67610. /**
  67611. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67612. * @param context The context when loading the asset
  67613. * @param material The glTF material property
  67614. * @param assign A function called synchronously after parsing the glTF properties
  67615. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67616. */
  67617. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67618. /**
  67619. * Define this method to modify the default behavior when creating materials.
  67620. * @param context The context when loading the asset
  67621. * @param material The glTF material property
  67622. * @param babylonDrawMode The draw mode for the Babylon material
  67623. * @returns The Babylon material or null if not handled
  67624. */
  67625. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67626. /**
  67627. * Define this method to modify the default behavior when loading material properties.
  67628. * @param context The context when loading the asset
  67629. * @param material The glTF material property
  67630. * @param babylonMaterial The Babylon material
  67631. * @returns A promise that resolves when the load is complete or null if not handled
  67632. */
  67633. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67634. /**
  67635. * Define this method to modify the default behavior when loading texture infos.
  67636. * @param context The context when loading the asset
  67637. * @param textureInfo The glTF texture info property
  67638. * @param assign A function called synchronously after parsing the glTF properties
  67639. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67640. */
  67641. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67642. /**
  67643. * Define this method to modify the default behavior when loading animations.
  67644. * @param context The context when loading the asset
  67645. * @param animation The glTF animation property
  67646. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67647. */
  67648. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67649. /**
  67650. * @hidden Define this method to modify the default behavior when loading skins.
  67651. * @param context The context when loading the asset
  67652. * @param node The glTF node property
  67653. * @param skin The glTF skin property
  67654. * @returns A promise that resolves when the load is complete or null if not handled
  67655. */
  67656. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67657. /**
  67658. * @hidden Define this method to modify the default behavior when loading uris.
  67659. * @param context The context when loading the asset
  67660. * @param property The glTF property associated with the uri
  67661. * @param uri The uri to load
  67662. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67663. */
  67664. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67665. }
  67666. }
  67667. declare module BABYLON.GLTF2 {
  67668. /**
  67669. * Helper class for working with arrays when loading the glTF asset
  67670. */
  67671. export class ArrayItem {
  67672. /**
  67673. * Gets an item from the given array.
  67674. * @param context The context when loading the asset
  67675. * @param array The array to get the item from
  67676. * @param index The index to the array
  67677. * @returns The array item
  67678. */
  67679. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67680. /**
  67681. * Assign an `index` field to each item of the given array.
  67682. * @param array The array of items
  67683. */
  67684. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67685. }
  67686. /**
  67687. * The glTF 2.0 loader
  67688. */
  67689. export class GLTFLoader implements IGLTFLoader {
  67690. /** @hidden */
  67691. _completePromises: Promise<any>[];
  67692. private _disposed;
  67693. private _parent;
  67694. private _state;
  67695. private _extensions;
  67696. private _rootUrl;
  67697. private _fileName;
  67698. private _uniqueRootUrl;
  67699. private _gltf;
  67700. private _babylonScene;
  67701. private _rootBabylonMesh;
  67702. private _defaultBabylonMaterialData;
  67703. private _progressCallback?;
  67704. private _requests;
  67705. private static readonly _DefaultSampler;
  67706. private static _ExtensionNames;
  67707. private static _ExtensionFactories;
  67708. /**
  67709. * Registers a loader extension.
  67710. * @param name The name of the loader extension.
  67711. * @param factory The factory function that creates the loader extension.
  67712. */
  67713. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67714. /**
  67715. * Unregisters a loader extension.
  67716. * @param name The name of the loader extenion.
  67717. * @returns A boolean indicating whether the extension has been unregistered
  67718. */
  67719. static UnregisterExtension(name: string): boolean;
  67720. /**
  67721. * Gets the loader state.
  67722. */
  67723. readonly state: Nullable<GLTFLoaderState>;
  67724. /**
  67725. * The glTF object parsed from the JSON.
  67726. */
  67727. readonly gltf: IGLTF;
  67728. /**
  67729. * The Babylon scene when loading the asset.
  67730. */
  67731. readonly babylonScene: Scene;
  67732. /**
  67733. * The root Babylon mesh when loading the asset.
  67734. */
  67735. readonly rootBabylonMesh: Mesh;
  67736. /** @hidden */
  67737. constructor(parent: GLTFFileLoader);
  67738. /** @hidden */
  67739. dispose(): void;
  67740. /** @hidden */
  67741. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67742. meshes: AbstractMesh[];
  67743. particleSystems: IParticleSystem[];
  67744. skeletons: Skeleton[];
  67745. animationGroups: AnimationGroup[];
  67746. }>;
  67747. /** @hidden */
  67748. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67749. private _loadAsync;
  67750. private _loadData;
  67751. private _setupData;
  67752. private _loadExtensions;
  67753. private _checkExtensions;
  67754. private _setState;
  67755. private _createRootNode;
  67756. /**
  67757. * Loads a glTF scene.
  67758. * @param context The context when loading the asset
  67759. * @param scene The glTF scene property
  67760. * @returns A promise that resolves when the load is complete
  67761. */
  67762. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67763. private _forEachPrimitive;
  67764. private _getMeshes;
  67765. private _getSkeletons;
  67766. private _getAnimationGroups;
  67767. private _startAnimations;
  67768. /**
  67769. * Loads a glTF node.
  67770. * @param context The context when loading the asset
  67771. * @param node The glTF node property
  67772. * @param assign A function called synchronously after parsing the glTF properties
  67773. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67774. */
  67775. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67776. private _loadMeshAsync;
  67777. /**
  67778. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67779. * @param context The context when loading the asset
  67780. * @param name The mesh name when loading the asset
  67781. * @param node The glTF node when loading the asset
  67782. * @param mesh The glTF mesh when loading the asset
  67783. * @param primitive The glTF mesh primitive property
  67784. * @param assign A function called synchronously after parsing the glTF properties
  67785. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67786. */
  67787. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67788. private _loadVertexDataAsync;
  67789. private _createMorphTargets;
  67790. private _loadMorphTargetsAsync;
  67791. private _loadMorphTargetVertexDataAsync;
  67792. private static _LoadTransform;
  67793. private _loadSkinAsync;
  67794. private _loadBones;
  67795. private _loadBone;
  67796. private _loadSkinInverseBindMatricesDataAsync;
  67797. private _updateBoneMatrices;
  67798. private _getNodeMatrix;
  67799. /**
  67800. * Loads a glTF camera.
  67801. * @param context The context when loading the asset
  67802. * @param camera The glTF camera property
  67803. * @param assign A function called synchronously after parsing the glTF properties
  67804. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67805. */
  67806. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67807. private _loadAnimationsAsync;
  67808. /**
  67809. * Loads a glTF animation.
  67810. * @param context The context when loading the asset
  67811. * @param animation The glTF animation property
  67812. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67813. */
  67814. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67815. /**
  67816. * @hidden Loads a glTF animation channel.
  67817. * @param context The context when loading the asset
  67818. * @param animationContext The context of the animation when loading the asset
  67819. * @param animation The glTF animation property
  67820. * @param channel The glTF animation channel property
  67821. * @param babylonAnimationGroup The babylon animation group property
  67822. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67823. * @returns A void promise when the channel load is complete
  67824. */
  67825. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67826. private _loadAnimationSamplerAsync;
  67827. private _loadBufferAsync;
  67828. /**
  67829. * Loads a glTF buffer view.
  67830. * @param context The context when loading the asset
  67831. * @param bufferView The glTF buffer view property
  67832. * @returns A promise that resolves with the loaded data when the load is complete
  67833. */
  67834. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67835. private _loadAccessorAsync;
  67836. private _loadFloatAccessorAsync;
  67837. private _loadIndicesAccessorAsync;
  67838. private _loadVertexBufferViewAsync;
  67839. private _loadVertexAccessorAsync;
  67840. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67841. /** @hidden */
  67842. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67843. private _createDefaultMaterial;
  67844. /**
  67845. * Creates a Babylon material from a glTF material.
  67846. * @param context The context when loading the asset
  67847. * @param material The glTF material property
  67848. * @param babylonDrawMode The draw mode for the Babylon material
  67849. * @returns The Babylon material
  67850. */
  67851. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67852. /**
  67853. * Loads properties from a glTF material into a Babylon material.
  67854. * @param context The context when loading the asset
  67855. * @param material The glTF material property
  67856. * @param babylonMaterial The Babylon material
  67857. * @returns A promise that resolves when the load is complete
  67858. */
  67859. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67860. /**
  67861. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67862. * @param context The context when loading the asset
  67863. * @param material The glTF material property
  67864. * @param babylonMaterial The Babylon material
  67865. * @returns A promise that resolves when the load is complete
  67866. */
  67867. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67868. /**
  67869. * Loads the alpha properties from a glTF material into a Babylon material.
  67870. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67871. * @param context The context when loading the asset
  67872. * @param material The glTF material property
  67873. * @param babylonMaterial The Babylon material
  67874. */
  67875. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67876. /**
  67877. * Loads a glTF texture info.
  67878. * @param context The context when loading the asset
  67879. * @param textureInfo The glTF texture info property
  67880. * @param assign A function called synchronously after parsing the glTF properties
  67881. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67882. */
  67883. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67884. private _loadTextureAsync;
  67885. private _loadSampler;
  67886. /**
  67887. * Loads a glTF image.
  67888. * @param context The context when loading the asset
  67889. * @param image The glTF image property
  67890. * @returns A promise that resolves with the loaded data when the load is complete
  67891. */
  67892. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67893. /**
  67894. * Loads a glTF uri.
  67895. * @param context The context when loading the asset
  67896. * @param property The glTF property associated with the uri
  67897. * @param uri The base64 or relative uri
  67898. * @returns A promise that resolves with the loaded data when the load is complete
  67899. */
  67900. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67901. private _onProgress;
  67902. /**
  67903. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67904. * @param babylonObject the Babylon object with metadata
  67905. * @param pointer the JSON pointer
  67906. */
  67907. static AddPointerMetadata(babylonObject: {
  67908. metadata: any;
  67909. }, pointer: string): void;
  67910. private static _GetTextureWrapMode;
  67911. private static _GetTextureSamplingMode;
  67912. private static _GetTypedArrayConstructor;
  67913. private static _GetTypedArray;
  67914. private static _GetNumComponents;
  67915. private static _ValidateUri;
  67916. private static _GetDrawMode;
  67917. private _compileMaterialsAsync;
  67918. private _compileShadowGeneratorsAsync;
  67919. private _forEachExtensions;
  67920. private _applyExtensions;
  67921. private _extensionsOnLoading;
  67922. private _extensionsOnReady;
  67923. private _extensionsLoadSceneAsync;
  67924. private _extensionsLoadNodeAsync;
  67925. private _extensionsLoadCameraAsync;
  67926. private _extensionsLoadVertexDataAsync;
  67927. private _extensionsLoadMeshPrimitiveAsync;
  67928. private _extensionsLoadMaterialAsync;
  67929. private _extensionsCreateMaterial;
  67930. private _extensionsLoadMaterialPropertiesAsync;
  67931. private _extensionsLoadTextureInfoAsync;
  67932. private _extensionsLoadAnimationAsync;
  67933. private _extensionsLoadSkinAsync;
  67934. private _extensionsLoadUriAsync;
  67935. /**
  67936. * Helper method called by a loader extension to load an glTF extension.
  67937. * @param context The context when loading the asset
  67938. * @param property The glTF property to load the extension from
  67939. * @param extensionName The name of the extension to load
  67940. * @param actionAsync The action to run
  67941. * @returns The promise returned by actionAsync or null if the extension does not exist
  67942. */
  67943. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67944. /**
  67945. * Helper method called by a loader extension to load a glTF extra.
  67946. * @param context The context when loading the asset
  67947. * @param property The glTF property to load the extra from
  67948. * @param extensionName The name of the extension to load
  67949. * @param actionAsync The action to run
  67950. * @returns The promise returned by actionAsync or null if the extra does not exist
  67951. */
  67952. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67953. /**
  67954. * Increments the indentation level and logs a message.
  67955. * @param message The message to log
  67956. */
  67957. logOpen(message: string): void;
  67958. /**
  67959. * Decrements the indentation level.
  67960. */
  67961. logClose(): void;
  67962. /**
  67963. * Logs a message
  67964. * @param message The message to log
  67965. */
  67966. log(message: string): void;
  67967. /**
  67968. * Starts a performance counter.
  67969. * @param counterName The name of the performance counter
  67970. */
  67971. startPerformanceCounter(counterName: string): void;
  67972. /**
  67973. * Ends a performance counter.
  67974. * @param counterName The name of the performance counter
  67975. */
  67976. endPerformanceCounter(counterName: string): void;
  67977. }
  67978. }
  67979. declare module BABYLON.GLTF2.Loader.Extensions {
  67980. /**
  67981. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67982. */
  67983. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67984. /** The name of this extension. */
  67985. readonly name: string;
  67986. /** Defines whether this extension is enabled. */
  67987. enabled: boolean;
  67988. private _loader;
  67989. private _lights?;
  67990. /** @hidden */
  67991. constructor(loader: GLTFLoader);
  67992. /** @hidden */
  67993. dispose(): void;
  67994. /** @hidden */
  67995. onLoading(): void;
  67996. /** @hidden */
  67997. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67998. private _loadLightAsync;
  67999. }
  68000. }
  68001. declare module BABYLON.GLTF2.Loader.Extensions {
  68002. /**
  68003. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68004. */
  68005. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68006. /** The name of this extension. */
  68007. readonly name: string;
  68008. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68009. dracoCompression?: DracoCompression;
  68010. /** Defines whether this extension is enabled. */
  68011. enabled: boolean;
  68012. private _loader;
  68013. /** @hidden */
  68014. constructor(loader: GLTFLoader);
  68015. /** @hidden */
  68016. dispose(): void;
  68017. /** @hidden */
  68018. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68019. }
  68020. }
  68021. declare module BABYLON.GLTF2.Loader.Extensions {
  68022. /**
  68023. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68024. */
  68025. export class KHR_lights implements IGLTFLoaderExtension {
  68026. /** The name of this extension. */
  68027. readonly name: string;
  68028. /** Defines whether this extension is enabled. */
  68029. enabled: boolean;
  68030. private _loader;
  68031. private _lights?;
  68032. /** @hidden */
  68033. constructor(loader: GLTFLoader);
  68034. /** @hidden */
  68035. dispose(): void;
  68036. /** @hidden */
  68037. onLoading(): void;
  68038. /** @hidden */
  68039. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68040. }
  68041. }
  68042. declare module BABYLON.GLTF2.Loader.Extensions {
  68043. /**
  68044. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68045. */
  68046. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68047. /** The name of this extension. */
  68048. readonly name: string;
  68049. /** Defines whether this extension is enabled. */
  68050. enabled: boolean;
  68051. private _loader;
  68052. /** @hidden */
  68053. constructor(loader: GLTFLoader);
  68054. /** @hidden */
  68055. dispose(): void;
  68056. /** @hidden */
  68057. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68058. private _loadSpecularGlossinessPropertiesAsync;
  68059. }
  68060. }
  68061. declare module BABYLON.GLTF2.Loader.Extensions {
  68062. /**
  68063. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68064. */
  68065. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68066. /** The name of this extension. */
  68067. readonly name: string;
  68068. /** Defines whether this extension is enabled. */
  68069. enabled: boolean;
  68070. private _loader;
  68071. /** @hidden */
  68072. constructor(loader: GLTFLoader);
  68073. /** @hidden */
  68074. dispose(): void;
  68075. /** @hidden */
  68076. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68077. private _loadUnlitPropertiesAsync;
  68078. }
  68079. }
  68080. declare module BABYLON.GLTF2.Loader.Extensions {
  68081. /**
  68082. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68083. */
  68084. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68085. /** The name of this extension. */
  68086. readonly name: string;
  68087. /** Defines whether this extension is enabled. */
  68088. enabled: boolean;
  68089. private _loader;
  68090. /** @hidden */
  68091. constructor(loader: GLTFLoader);
  68092. /** @hidden */
  68093. dispose(): void;
  68094. /** @hidden */
  68095. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68096. }
  68097. }
  68098. declare module BABYLON.GLTF2.Loader.Extensions {
  68099. /**
  68100. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68101. */
  68102. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68103. /** The name of this extension. */
  68104. readonly name: string;
  68105. /** Defines whether this extension is enabled. */
  68106. enabled: boolean;
  68107. private _loader;
  68108. private _clips;
  68109. private _emitters;
  68110. /** @hidden */
  68111. constructor(loader: GLTFLoader);
  68112. /** @hidden */
  68113. dispose(): void;
  68114. /** @hidden */
  68115. onLoading(): void;
  68116. /** @hidden */
  68117. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68118. /** @hidden */
  68119. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68120. /** @hidden */
  68121. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68122. private _loadClipAsync;
  68123. private _loadEmitterAsync;
  68124. private _getEventAction;
  68125. private _loadAnimationEventAsync;
  68126. }
  68127. }
  68128. declare module BABYLON.GLTF2.Loader.Extensions {
  68129. /**
  68130. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68131. */
  68132. export class MSFT_lod implements IGLTFLoaderExtension {
  68133. /** The name of this extension. */
  68134. readonly name: string;
  68135. /** Defines whether this extension is enabled. */
  68136. enabled: boolean;
  68137. /**
  68138. * Maximum number of LODs to load, starting from the lowest LOD.
  68139. */
  68140. maxLODsToLoad: number;
  68141. /**
  68142. * Observable raised when all node LODs of one level are loaded.
  68143. * The event data is the index of the loaded LOD starting from zero.
  68144. * Dispose the loader to cancel the loading of the next level of LODs.
  68145. */
  68146. onNodeLODsLoadedObservable: Observable<number>;
  68147. /**
  68148. * Observable raised when all material LODs of one level are loaded.
  68149. * The event data is the index of the loaded LOD starting from zero.
  68150. * Dispose the loader to cancel the loading of the next level of LODs.
  68151. */
  68152. onMaterialLODsLoadedObservable: Observable<number>;
  68153. private _loader;
  68154. private _nodeIndexLOD;
  68155. private _nodeSignalLODs;
  68156. private _nodePromiseLODs;
  68157. private _materialIndexLOD;
  68158. private _materialSignalLODs;
  68159. private _materialPromiseLODs;
  68160. /** @hidden */
  68161. constructor(loader: GLTFLoader);
  68162. /** @hidden */
  68163. dispose(): void;
  68164. /** @hidden */
  68165. onReady(): void;
  68166. /** @hidden */
  68167. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68168. /** @hidden */
  68169. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68170. /** @hidden */
  68171. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68172. /**
  68173. * Gets an array of LOD properties from lowest to highest.
  68174. */
  68175. private _getLODs;
  68176. private _disposeUnusedMaterials;
  68177. }
  68178. }
  68179. declare module BABYLON.GLTF2.Loader.Extensions {
  68180. /** @hidden */
  68181. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68182. readonly name: string;
  68183. enabled: boolean;
  68184. private _loader;
  68185. constructor(loader: GLTFLoader);
  68186. dispose(): void;
  68187. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68188. }
  68189. }
  68190. declare module BABYLON.GLTF2.Loader.Extensions {
  68191. /** @hidden */
  68192. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68193. readonly name: string;
  68194. enabled: boolean;
  68195. private _loader;
  68196. constructor(loader: GLTFLoader);
  68197. dispose(): void;
  68198. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68199. }
  68200. }
  68201. declare module BABYLON.GLTF2.Loader.Extensions {
  68202. /**
  68203. * Store glTF extras (if present) in BJS objects' metadata
  68204. */
  68205. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68206. /** The name of this extension. */
  68207. readonly name: string;
  68208. /** Defines whether this extension is enabled. */
  68209. enabled: boolean;
  68210. private _loader;
  68211. private _assignExtras;
  68212. /** @hidden */
  68213. constructor(loader: GLTFLoader);
  68214. /** @hidden */
  68215. dispose(): void;
  68216. /** @hidden */
  68217. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68218. /** @hidden */
  68219. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68220. /** @hidden */
  68221. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68222. }
  68223. }
  68224. declare module BABYLON {
  68225. /**
  68226. * Class reading and parsing the MTL file bundled with the obj file.
  68227. */
  68228. export class MTLFileLoader {
  68229. /**
  68230. * All material loaded from the mtl will be set here
  68231. */
  68232. materials: StandardMaterial[];
  68233. /**
  68234. * This function will read the mtl file and create each material described inside
  68235. * This function could be improve by adding :
  68236. * -some component missing (Ni, Tf...)
  68237. * -including the specific options available
  68238. *
  68239. * @param scene defines the scene the material will be created in
  68240. * @param data defines the mtl data to parse
  68241. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68242. */
  68243. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68244. /**
  68245. * Gets the texture for the material.
  68246. *
  68247. * If the material is imported from input file,
  68248. * We sanitize the url to ensure it takes the textre from aside the material.
  68249. *
  68250. * @param rootUrl The root url to load from
  68251. * @param value The value stored in the mtl
  68252. * @return The Texture
  68253. */
  68254. private static _getTexture;
  68255. }
  68256. /**
  68257. * Options for loading OBJ/MTL files
  68258. */
  68259. type MeshLoadOptions = {
  68260. /**
  68261. * Defines if UVs are optimized by default during load.
  68262. */
  68263. OptimizeWithUV: boolean;
  68264. /**
  68265. * Defines custom scaling of UV coordinates of loaded meshes.
  68266. */
  68267. UVScaling: Vector2;
  68268. /**
  68269. * Invert model on y-axis (does a model scaling inversion)
  68270. */
  68271. InvertY: boolean;
  68272. /**
  68273. * Invert Y-Axis of referenced textures on load
  68274. */
  68275. InvertTextureY: boolean;
  68276. /**
  68277. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68278. */
  68279. ImportVertexColors: boolean;
  68280. /**
  68281. * Compute the normals for the model, even if normals are present in the file.
  68282. */
  68283. ComputeNormals: boolean;
  68284. /**
  68285. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68286. */
  68287. SkipMaterials: boolean;
  68288. /**
  68289. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68290. */
  68291. MaterialLoadingFailsSilently: boolean;
  68292. };
  68293. /**
  68294. * OBJ file type loader.
  68295. * This is a babylon scene loader plugin.
  68296. */
  68297. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68298. /**
  68299. * Defines if UVs are optimized by default during load.
  68300. */
  68301. static OPTIMIZE_WITH_UV: boolean;
  68302. /**
  68303. * Invert model on y-axis (does a model scaling inversion)
  68304. */
  68305. static INVERT_Y: boolean;
  68306. /**
  68307. * Invert Y-Axis of referenced textures on load
  68308. */
  68309. static INVERT_TEXTURE_Y: boolean;
  68310. /**
  68311. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68312. */
  68313. static IMPORT_VERTEX_COLORS: boolean;
  68314. /**
  68315. * Compute the normals for the model, even if normals are present in the file.
  68316. */
  68317. static COMPUTE_NORMALS: boolean;
  68318. /**
  68319. * Defines custom scaling of UV coordinates of loaded meshes.
  68320. */
  68321. static UV_SCALING: Vector2;
  68322. /**
  68323. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68324. */
  68325. static SKIP_MATERIALS: boolean;
  68326. /**
  68327. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68328. *
  68329. * Defaults to true for backwards compatibility.
  68330. */
  68331. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68332. /**
  68333. * Defines the name of the plugin.
  68334. */
  68335. name: string;
  68336. /**
  68337. * Defines the extension the plugin is able to load.
  68338. */
  68339. extensions: string;
  68340. /** @hidden */
  68341. obj: RegExp;
  68342. /** @hidden */
  68343. group: RegExp;
  68344. /** @hidden */
  68345. mtllib: RegExp;
  68346. /** @hidden */
  68347. usemtl: RegExp;
  68348. /** @hidden */
  68349. smooth: RegExp;
  68350. /** @hidden */
  68351. vertexPattern: RegExp;
  68352. /** @hidden */
  68353. normalPattern: RegExp;
  68354. /** @hidden */
  68355. uvPattern: RegExp;
  68356. /** @hidden */
  68357. facePattern1: RegExp;
  68358. /** @hidden */
  68359. facePattern2: RegExp;
  68360. /** @hidden */
  68361. facePattern3: RegExp;
  68362. /** @hidden */
  68363. facePattern4: RegExp;
  68364. /** @hidden */
  68365. facePattern5: RegExp;
  68366. private _meshLoadOptions;
  68367. /**
  68368. * Creates loader for .OBJ files
  68369. *
  68370. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68371. */
  68372. constructor(meshLoadOptions?: MeshLoadOptions);
  68373. private static readonly currentMeshLoadOptions;
  68374. /**
  68375. * Calls synchronously the MTL file attached to this obj.
  68376. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68377. * Without this function materials are not displayed in the first frame (but displayed after).
  68378. * In consequence it is impossible to get material information in your HTML file
  68379. *
  68380. * @param url The URL of the MTL file
  68381. * @param rootUrl
  68382. * @param onSuccess Callback function to be called when the MTL file is loaded
  68383. * @private
  68384. */
  68385. private _loadMTL;
  68386. /**
  68387. * Instantiates a OBJ file loader plugin.
  68388. * @returns the created plugin
  68389. */
  68390. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68391. /**
  68392. * If the data string can be loaded directly.
  68393. *
  68394. * @param data string containing the file data
  68395. * @returns if the data can be loaded directly
  68396. */
  68397. canDirectLoad(data: string): boolean;
  68398. /**
  68399. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68400. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68401. * @param scene the scene the meshes should be added to
  68402. * @param data the OBJ data to load
  68403. * @param rootUrl root url to load from
  68404. * @param onProgress event that fires when loading progress has occured
  68405. * @param fileName Defines the name of the file to load
  68406. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68407. */
  68408. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68409. meshes: AbstractMesh[];
  68410. particleSystems: IParticleSystem[];
  68411. skeletons: Skeleton[];
  68412. animationGroups: AnimationGroup[];
  68413. }>;
  68414. /**
  68415. * Imports all objects from the loaded OBJ data and adds them to the scene
  68416. * @param scene the scene the objects should be added to
  68417. * @param data the OBJ data to load
  68418. * @param rootUrl root url to load from
  68419. * @param onProgress event that fires when loading progress has occured
  68420. * @param fileName Defines the name of the file to load
  68421. * @returns a promise which completes when objects have been loaded to the scene
  68422. */
  68423. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68424. /**
  68425. * Load into an asset container.
  68426. * @param scene The scene to load into
  68427. * @param data The data to import
  68428. * @param rootUrl The root url for scene and resources
  68429. * @param onProgress The callback when the load progresses
  68430. * @param fileName Defines the name of the file to load
  68431. * @returns The loaded asset container
  68432. */
  68433. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68434. /**
  68435. * Read the OBJ file and create an Array of meshes.
  68436. * Each mesh contains all information given by the OBJ and the MTL file.
  68437. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68438. *
  68439. * @param meshesNames
  68440. * @param scene Scene The scene where are displayed the data
  68441. * @param data String The content of the obj file
  68442. * @param rootUrl String The path to the folder
  68443. * @returns Array<AbstractMesh>
  68444. * @private
  68445. */
  68446. private _parseSolid;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /**
  68451. * STL file type loader.
  68452. * This is a babylon scene loader plugin.
  68453. */
  68454. export class STLFileLoader implements ISceneLoaderPlugin {
  68455. /** @hidden */
  68456. solidPattern: RegExp;
  68457. /** @hidden */
  68458. facetsPattern: RegExp;
  68459. /** @hidden */
  68460. normalPattern: RegExp;
  68461. /** @hidden */
  68462. vertexPattern: RegExp;
  68463. /**
  68464. * Defines the name of the plugin.
  68465. */
  68466. name: string;
  68467. /**
  68468. * Defines the extensions the stl loader is able to load.
  68469. * force data to come in as an ArrayBuffer
  68470. * we'll convert to string if it looks like it's an ASCII .stl
  68471. */
  68472. extensions: ISceneLoaderPluginExtensions;
  68473. /**
  68474. * Import meshes into a scene.
  68475. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68476. * @param scene The scene to import into
  68477. * @param data The data to import
  68478. * @param rootUrl The root url for scene and resources
  68479. * @param meshes The meshes array to import into
  68480. * @param particleSystems The particle systems array to import into
  68481. * @param skeletons The skeletons array to import into
  68482. * @param onError The callback when import fails
  68483. * @returns True if successful or false otherwise
  68484. */
  68485. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68486. /**
  68487. * Load into a scene.
  68488. * @param scene The scene to load into
  68489. * @param data The data to import
  68490. * @param rootUrl The root url for scene and resources
  68491. * @param onError The callback when import fails
  68492. * @returns true if successful or false otherwise
  68493. */
  68494. load(scene: Scene, data: any, rootUrl: string): boolean;
  68495. /**
  68496. * Load into an asset container.
  68497. * @param scene The scene to load into
  68498. * @param data The data to import
  68499. * @param rootUrl The root url for scene and resources
  68500. * @param onError The callback when import fails
  68501. * @returns The loaded asset container
  68502. */
  68503. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68504. private _isBinary;
  68505. private _parseBinary;
  68506. private _parseASCII;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /**
  68511. * Class for generating OBJ data from a Babylon scene.
  68512. */
  68513. export class OBJExport {
  68514. /**
  68515. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68516. * @param mesh defines the list of meshes to serialize
  68517. * @param materials defines if materials should be exported
  68518. * @param matlibname defines the name of the associated mtl file
  68519. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68520. * @returns the OBJ content
  68521. */
  68522. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68523. /**
  68524. * Exports the material(s) of a mesh in .MTL file format (text)
  68525. * @param mesh defines the mesh to extract the material from
  68526. * @returns the mtl content
  68527. */
  68528. static MTL(mesh: Mesh): string;
  68529. }
  68530. }
  68531. declare module BABYLON {
  68532. /** @hidden */
  68533. export var __IGLTFExporterExtension: number;
  68534. /**
  68535. * Interface for extending the exporter
  68536. * @hidden
  68537. */
  68538. export interface IGLTFExporterExtension {
  68539. /**
  68540. * The name of this extension
  68541. */
  68542. readonly name: string;
  68543. /**
  68544. * Defines whether this extension is enabled
  68545. */
  68546. enabled: boolean;
  68547. /**
  68548. * Defines whether this extension is required
  68549. */
  68550. required: boolean;
  68551. }
  68552. }
  68553. declare module BABYLON.GLTF2.Exporter {
  68554. /** @hidden */
  68555. export var __IGLTFExporterExtensionV2: number;
  68556. /**
  68557. * Interface for a glTF exporter extension
  68558. * @hidden
  68559. */
  68560. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68561. /**
  68562. * Define this method to modify the default behavior before exporting a texture
  68563. * @param context The context when loading the asset
  68564. * @param babylonTexture The glTF texture info property
  68565. * @param mimeType The mime-type of the generated image
  68566. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68567. */
  68568. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68569. /**
  68570. * Define this method to modify the default behavior when exporting texture info
  68571. * @param context The context when loading the asset
  68572. * @param meshPrimitive glTF mesh primitive
  68573. * @param babylonSubMesh Babylon submesh
  68574. * @param binaryWriter glTF serializer binary writer instance
  68575. * @returns nullable IMeshPrimitive promise
  68576. */
  68577. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68578. /**
  68579. * Define this method to modify the default behavior when exporting a node
  68580. * @param context The context when exporting the node
  68581. * @param node glTF node
  68582. * @param babylonNode BabylonJS node
  68583. * @returns nullable INode promise
  68584. */
  68585. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68586. /**
  68587. * Called after the exporter state changes to EXPORTING
  68588. */
  68589. onExporting?(): void;
  68590. }
  68591. }
  68592. declare module BABYLON.GLTF2.Exporter {
  68593. /**
  68594. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68595. * @hidden
  68596. */
  68597. export class _GLTFMaterialExporter {
  68598. /**
  68599. * Represents the dielectric specular values for R, G and B
  68600. */
  68601. private static readonly _DielectricSpecular;
  68602. /**
  68603. * Allows the maximum specular power to be defined for material calculations
  68604. */
  68605. private static readonly _MaxSpecularPower;
  68606. /**
  68607. * Mapping to store textures
  68608. */
  68609. private _textureMap;
  68610. /**
  68611. * Numeric tolerance value
  68612. */
  68613. private static readonly _Epsilon;
  68614. /**
  68615. * Reference to the glTF Exporter
  68616. */
  68617. private _exporter;
  68618. constructor(exporter: _Exporter);
  68619. /**
  68620. * Specifies if two colors are approximately equal in value
  68621. * @param color1 first color to compare to
  68622. * @param color2 second color to compare to
  68623. * @param epsilon threshold value
  68624. */
  68625. private static FuzzyEquals;
  68626. /**
  68627. * Gets the materials from a Babylon scene and converts them to glTF materials
  68628. * @param scene babylonjs scene
  68629. * @param mimeType texture mime type
  68630. * @param images array of images
  68631. * @param textures array of textures
  68632. * @param materials array of materials
  68633. * @param imageData mapping of texture names to base64 textures
  68634. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68635. */
  68636. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68637. /**
  68638. * Makes a copy of the glTF material without the texture parameters
  68639. * @param originalMaterial original glTF material
  68640. * @returns glTF material without texture parameters
  68641. */
  68642. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68643. /**
  68644. * Specifies if the material has any texture parameters present
  68645. * @param material glTF Material
  68646. * @returns boolean specifying if texture parameters are present
  68647. */
  68648. _hasTexturesPresent(material: IMaterial): boolean;
  68649. /**
  68650. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68651. * @param babylonStandardMaterial
  68652. * @returns glTF Metallic Roughness Material representation
  68653. */
  68654. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68655. /**
  68656. * Computes the metallic factor
  68657. * @param diffuse diffused value
  68658. * @param specular specular value
  68659. * @param oneMinusSpecularStrength one minus the specular strength
  68660. * @returns metallic value
  68661. */
  68662. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68663. /**
  68664. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68665. * @param glTFMaterial glTF material
  68666. * @param babylonMaterial Babylon material
  68667. */
  68668. private static _SetAlphaMode;
  68669. /**
  68670. * Converts a Babylon Standard Material to a glTF Material
  68671. * @param babylonStandardMaterial BJS Standard Material
  68672. * @param mimeType mime type to use for the textures
  68673. * @param images array of glTF image interfaces
  68674. * @param textures array of glTF texture interfaces
  68675. * @param materials array of glTF material interfaces
  68676. * @param imageData map of image file name to data
  68677. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68678. */
  68679. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68680. /**
  68681. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68682. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68683. * @param mimeType mime type to use for the textures
  68684. * @param images array of glTF image interfaces
  68685. * @param textures array of glTF texture interfaces
  68686. * @param materials array of glTF material interfaces
  68687. * @param imageData map of image file name to data
  68688. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68689. */
  68690. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68691. /**
  68692. * Converts an image typed array buffer to a base64 image
  68693. * @param buffer typed array buffer
  68694. * @param width width of the image
  68695. * @param height height of the image
  68696. * @param mimeType mimetype of the image
  68697. * @returns base64 image string
  68698. */
  68699. private _createBase64FromCanvasAsync;
  68700. /**
  68701. * Generates a white texture based on the specified width and height
  68702. * @param width width of the texture in pixels
  68703. * @param height height of the texture in pixels
  68704. * @param scene babylonjs scene
  68705. * @returns white texture
  68706. */
  68707. private _createWhiteTexture;
  68708. /**
  68709. * 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
  68710. * @param texture1 first texture to resize
  68711. * @param texture2 second texture to resize
  68712. * @param scene babylonjs scene
  68713. * @returns resized textures or null
  68714. */
  68715. private _resizeTexturesToSameDimensions;
  68716. /**
  68717. * Converts an array of pixels to a Float32Array
  68718. * Throws an error if the pixel format is not supported
  68719. * @param pixels - array buffer containing pixel values
  68720. * @returns Float32 of pixels
  68721. */
  68722. private _convertPixelArrayToFloat32;
  68723. /**
  68724. * Convert Specular Glossiness Textures to Metallic Roughness
  68725. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68726. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68727. * @param diffuseTexture texture used to store diffuse information
  68728. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68729. * @param factors specular glossiness material factors
  68730. * @param mimeType the mime type to use for the texture
  68731. * @returns pbr metallic roughness interface or null
  68732. */
  68733. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68734. /**
  68735. * Converts specular glossiness material properties to metallic roughness
  68736. * @param specularGlossiness interface with specular glossiness material properties
  68737. * @returns interface with metallic roughness material properties
  68738. */
  68739. private _convertSpecularGlossinessToMetallicRoughness;
  68740. /**
  68741. * Calculates the surface reflectance, independent of lighting conditions
  68742. * @param color Color source to calculate brightness from
  68743. * @returns number representing the perceived brightness, or zero if color is undefined
  68744. */
  68745. private _getPerceivedBrightness;
  68746. /**
  68747. * Returns the maximum color component value
  68748. * @param color
  68749. * @returns maximum color component value, or zero if color is null or undefined
  68750. */
  68751. private _getMaxComponent;
  68752. /**
  68753. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68754. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68755. * @param mimeType mime type to use for the textures
  68756. * @param images array of glTF image interfaces
  68757. * @param textures array of glTF texture interfaces
  68758. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68759. * @param imageData map of image file name to data
  68760. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68761. * @returns glTF PBR Metallic Roughness factors
  68762. */
  68763. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68764. private _getGLTFTextureSampler;
  68765. private _getGLTFTextureWrapMode;
  68766. private _getGLTFTextureWrapModesSampler;
  68767. /**
  68768. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68769. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68770. * @param mimeType mime type to use for the textures
  68771. * @param images array of glTF image interfaces
  68772. * @param textures array of glTF texture interfaces
  68773. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68774. * @param imageData map of image file name to data
  68775. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68776. * @returns glTF PBR Metallic Roughness factors
  68777. */
  68778. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68779. /**
  68780. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68781. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68782. * @param mimeType mime type to use for the textures
  68783. * @param images array of glTF image interfaces
  68784. * @param textures array of glTF texture interfaces
  68785. * @param materials array of glTF material interfaces
  68786. * @param imageData map of image file name to data
  68787. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68788. */
  68789. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68790. private setMetallicRoughnessPbrMaterial;
  68791. private getPixelsFromTexture;
  68792. /**
  68793. * Extracts a texture from a Babylon texture into file data and glTF data
  68794. * @param babylonTexture Babylon texture to extract
  68795. * @param mimeType Mime Type of the babylonTexture
  68796. * @return glTF texture info, or null if the texture format is not supported
  68797. */
  68798. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68799. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68800. /**
  68801. * Builds a texture from base64 string
  68802. * @param base64Texture base64 texture string
  68803. * @param baseTextureName Name to use for the texture
  68804. * @param mimeType image mime type for the texture
  68805. * @param images array of images
  68806. * @param textures array of textures
  68807. * @param imageData map of image data
  68808. * @returns glTF texture info, or null if the texture format is not supported
  68809. */
  68810. private _getTextureInfoFromBase64;
  68811. }
  68812. }
  68813. declare module BABYLON {
  68814. /**
  68815. * Class for holding and downloading glTF file data
  68816. */
  68817. export class GLTFData {
  68818. /**
  68819. * Object which contains the file name as the key and its data as the value
  68820. */
  68821. glTFFiles: {
  68822. [fileName: string]: string | Blob;
  68823. };
  68824. /**
  68825. * Initializes the glTF file object
  68826. */
  68827. constructor();
  68828. /**
  68829. * Downloads the glTF data as files based on their names and data
  68830. */
  68831. downloadFiles(): void;
  68832. }
  68833. }
  68834. declare module BABYLON {
  68835. /**
  68836. * Holds a collection of exporter options and parameters
  68837. */
  68838. export interface IExportOptions {
  68839. /**
  68840. * Function which indicates whether a babylon node should be exported or not
  68841. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68842. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68843. */
  68844. shouldExportNode?(node: Node): boolean;
  68845. /**
  68846. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68847. * @param metadata source metadata to read from
  68848. * @returns the data to store to glTF node extras
  68849. */
  68850. metadataSelector?(metadata: any): any;
  68851. /**
  68852. * The sample rate to bake animation curves
  68853. */
  68854. animationSampleRate?: number;
  68855. /**
  68856. * Begin serialization without waiting for the scene to be ready
  68857. */
  68858. exportWithoutWaitingForScene?: boolean;
  68859. }
  68860. /**
  68861. * Class for generating glTF data from a Babylon scene.
  68862. */
  68863. export class GLTF2Export {
  68864. /**
  68865. * Exports the geometry of the scene to .gltf file format asynchronously
  68866. * @param scene Babylon scene with scene hierarchy information
  68867. * @param filePrefix File prefix to use when generating the glTF file
  68868. * @param options Exporter options
  68869. * @returns Returns an object with a .gltf file and associates texture names
  68870. * as keys and their data and paths as values
  68871. */
  68872. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68873. private static _PreExportAsync;
  68874. private static _PostExportAsync;
  68875. /**
  68876. * Exports the geometry of the scene to .glb file format asychronously
  68877. * @param scene Babylon scene with scene hierarchy information
  68878. * @param filePrefix File prefix to use when generating glb file
  68879. * @param options Exporter options
  68880. * @returns Returns an object with a .glb filename as key and data as value
  68881. */
  68882. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68883. }
  68884. }
  68885. declare module BABYLON.GLTF2.Exporter {
  68886. /**
  68887. * @hidden
  68888. */
  68889. export class _GLTFUtilities {
  68890. /**
  68891. * Creates a buffer view based on the supplied arguments
  68892. * @param bufferIndex index value of the specified buffer
  68893. * @param byteOffset byte offset value
  68894. * @param byteLength byte length of the bufferView
  68895. * @param byteStride byte distance between conequential elements
  68896. * @param name name of the buffer view
  68897. * @returns bufferView for glTF
  68898. */
  68899. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68900. /**
  68901. * Creates an accessor based on the supplied arguments
  68902. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68903. * @param name The name of the accessor
  68904. * @param type The type of the accessor
  68905. * @param componentType The datatype of components in the attribute
  68906. * @param count The number of attributes referenced by this accessor
  68907. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68908. * @param min Minimum value of each component in this attribute
  68909. * @param max Maximum value of each component in this attribute
  68910. * @returns accessor for glTF
  68911. */
  68912. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68913. /**
  68914. * Calculates the minimum and maximum values of an array of position floats
  68915. * @param positions Positions array of a mesh
  68916. * @param vertexStart Starting vertex offset to calculate min and max values
  68917. * @param vertexCount Number of vertices to check for min and max values
  68918. * @returns min number array and max number array
  68919. */
  68920. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68921. min: number[];
  68922. max: number[];
  68923. };
  68924. /**
  68925. * Converts a new right-handed Vector3
  68926. * @param vector vector3 array
  68927. * @returns right-handed Vector3
  68928. */
  68929. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68930. /**
  68931. * Converts a Vector3 to right-handed
  68932. * @param vector Vector3 to convert to right-handed
  68933. */
  68934. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68935. /**
  68936. * Converts a three element number array to right-handed
  68937. * @param vector number array to convert to right-handed
  68938. */
  68939. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68940. /**
  68941. * Converts a new right-handed Vector3
  68942. * @param vector vector3 array
  68943. * @returns right-handed Vector3
  68944. */
  68945. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68946. /**
  68947. * Converts a Vector3 to right-handed
  68948. * @param vector Vector3 to convert to right-handed
  68949. */
  68950. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68951. /**
  68952. * Converts a three element number array to right-handed
  68953. * @param vector number array to convert to right-handed
  68954. */
  68955. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68956. /**
  68957. * Converts a Vector4 to right-handed
  68958. * @param vector Vector4 to convert to right-handed
  68959. */
  68960. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68961. /**
  68962. * Converts a Vector4 to right-handed
  68963. * @param vector Vector4 to convert to right-handed
  68964. */
  68965. static _GetRightHandedArray4FromRef(vector: number[]): void;
  68966. /**
  68967. * Converts a Quaternion to right-handed
  68968. * @param quaternion Source quaternion to convert to right-handed
  68969. */
  68970. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68971. /**
  68972. * Converts a Quaternion to right-handed
  68973. * @param quaternion Source quaternion to convert to right-handed
  68974. */
  68975. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  68976. static _NormalizeTangentFromRef(tangent: Vector4): void;
  68977. }
  68978. }
  68979. declare module BABYLON.GLTF2.Exporter {
  68980. /**
  68981. * Converts Babylon Scene into glTF 2.0.
  68982. * @hidden
  68983. */
  68984. export class _Exporter {
  68985. /**
  68986. * Stores the glTF to export
  68987. */
  68988. _glTF: IGLTF;
  68989. /**
  68990. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68991. */
  68992. _bufferViews: IBufferView[];
  68993. /**
  68994. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68995. */
  68996. _accessors: IAccessor[];
  68997. /**
  68998. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68999. */
  69000. private _nodes;
  69001. /**
  69002. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69003. */
  69004. private _scenes;
  69005. /**
  69006. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69007. */
  69008. private _meshes;
  69009. /**
  69010. * Stores all the generated material information, which represents the appearance of each primitive
  69011. */
  69012. _materials: IMaterial[];
  69013. _materialMap: {
  69014. [materialID: number]: number;
  69015. };
  69016. /**
  69017. * Stores all the generated texture information, which is referenced by glTF materials
  69018. */
  69019. _textures: ITexture[];
  69020. /**
  69021. * Stores all the generated image information, which is referenced by glTF textures
  69022. */
  69023. _images: IImage[];
  69024. /**
  69025. * Stores all the texture samplers
  69026. */
  69027. _samplers: ISampler[];
  69028. /**
  69029. * Stores all the generated animation samplers, which is referenced by glTF animations
  69030. */
  69031. /**
  69032. * Stores the animations for glTF models
  69033. */
  69034. private _animations;
  69035. /**
  69036. * Stores the total amount of bytes stored in the glTF buffer
  69037. */
  69038. private _totalByteLength;
  69039. /**
  69040. * Stores a reference to the Babylon scene containing the source geometry and material information
  69041. */
  69042. _babylonScene: Scene;
  69043. /**
  69044. * Stores a map of the image data, where the key is the file name and the value
  69045. * is the image data
  69046. */
  69047. _imageData: {
  69048. [fileName: string]: {
  69049. data: Uint8Array;
  69050. mimeType: ImageMimeType;
  69051. };
  69052. };
  69053. /**
  69054. * Stores a map of the unique id of a node to its index in the node array
  69055. */
  69056. private _nodeMap;
  69057. /**
  69058. * Specifies if the Babylon scene should be converted to right-handed on export
  69059. */
  69060. _convertToRightHandedSystem: boolean;
  69061. /**
  69062. * Baked animation sample rate
  69063. */
  69064. private _animationSampleRate;
  69065. private _options;
  69066. private _localEngine;
  69067. _glTFMaterialExporter: _GLTFMaterialExporter;
  69068. private _extensions;
  69069. private static _ExtensionNames;
  69070. private static _ExtensionFactories;
  69071. private _applyExtensions;
  69072. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69073. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69074. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69075. private _forEachExtensions;
  69076. private _extensionsOnExporting;
  69077. /**
  69078. * Load glTF serializer extensions
  69079. */
  69080. private _loadExtensions;
  69081. /**
  69082. * Creates a glTF Exporter instance, which can accept optional exporter options
  69083. * @param babylonScene Babylon scene object
  69084. * @param options Options to modify the behavior of the exporter
  69085. */
  69086. constructor(babylonScene: Scene, options?: IExportOptions);
  69087. /**
  69088. * Registers a glTF exporter extension
  69089. * @param name Name of the extension to export
  69090. * @param factory The factory function that creates the exporter extension
  69091. */
  69092. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69093. /**
  69094. * Un-registers an exporter extension
  69095. * @param name The name fo the exporter extension
  69096. * @returns A boolean indicating whether the extension has been un-registered
  69097. */
  69098. static UnregisterExtension(name: string): boolean;
  69099. /**
  69100. * Lazy load a local engine with premultiplied alpha set to false
  69101. */
  69102. _getLocalEngine(): Engine;
  69103. private reorderIndicesBasedOnPrimitiveMode;
  69104. /**
  69105. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69106. * clock-wise during export to glTF
  69107. * @param submesh BabylonJS submesh
  69108. * @param primitiveMode Primitive mode of the mesh
  69109. * @param sideOrientation the winding order of the submesh
  69110. * @param vertexBufferKind The type of vertex attribute
  69111. * @param meshAttributeArray The vertex attribute data
  69112. * @param byteOffset The offset to the binary data
  69113. * @param binaryWriter The binary data for the glTF file
  69114. */
  69115. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69116. /**
  69117. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69118. * clock-wise during export to glTF
  69119. * @param submesh BabylonJS submesh
  69120. * @param primitiveMode Primitive mode of the mesh
  69121. * @param sideOrientation the winding order of the submesh
  69122. * @param vertexBufferKind The type of vertex attribute
  69123. * @param meshAttributeArray The vertex attribute data
  69124. * @param byteOffset The offset to the binary data
  69125. * @param binaryWriter The binary data for the glTF file
  69126. */
  69127. private reorderTriangleFillMode;
  69128. /**
  69129. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69130. * clock-wise during export to glTF
  69131. * @param submesh BabylonJS submesh
  69132. * @param primitiveMode Primitive mode of the mesh
  69133. * @param sideOrientation the winding order of the submesh
  69134. * @param vertexBufferKind The type of vertex attribute
  69135. * @param meshAttributeArray The vertex attribute data
  69136. * @param byteOffset The offset to the binary data
  69137. * @param binaryWriter The binary data for the glTF file
  69138. */
  69139. private reorderTriangleStripDrawMode;
  69140. /**
  69141. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69142. * clock-wise during export to glTF
  69143. * @param submesh BabylonJS submesh
  69144. * @param primitiveMode Primitive mode of the mesh
  69145. * @param sideOrientation the winding order of the submesh
  69146. * @param vertexBufferKind The type of vertex attribute
  69147. * @param meshAttributeArray The vertex attribute data
  69148. * @param byteOffset The offset to the binary data
  69149. * @param binaryWriter The binary data for the glTF file
  69150. */
  69151. private reorderTriangleFanMode;
  69152. /**
  69153. * Writes the vertex attribute data to binary
  69154. * @param vertices The vertices to write to the binary writer
  69155. * @param byteOffset The offset into the binary writer to overwrite binary data
  69156. * @param vertexAttributeKind The vertex attribute type
  69157. * @param meshAttributeArray The vertex attribute data
  69158. * @param binaryWriter The writer containing the binary data
  69159. */
  69160. private writeVertexAttributeData;
  69161. /**
  69162. * Writes mesh attribute data to a data buffer
  69163. * Returns the bytelength of the data
  69164. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69165. * @param meshAttributeArray Array containing the attribute data
  69166. * @param binaryWriter The buffer to write the binary data to
  69167. * @param indices Used to specify the order of the vertex data
  69168. */
  69169. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69170. /**
  69171. * Generates glTF json data
  69172. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69173. * @param glTFPrefix Text to use when prefixing a glTF file
  69174. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69175. * @returns json data as string
  69176. */
  69177. private generateJSON;
  69178. /**
  69179. * Generates data for .gltf and .bin files based on the glTF prefix string
  69180. * @param glTFPrefix Text to use when prefixing a glTF file
  69181. * @returns GLTFData with glTF file data
  69182. */
  69183. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69184. /**
  69185. * Creates a binary buffer for glTF
  69186. * @returns array buffer for binary data
  69187. */
  69188. private _generateBinaryAsync;
  69189. /**
  69190. * Pads the number to a multiple of 4
  69191. * @param num number to pad
  69192. * @returns padded number
  69193. */
  69194. private _getPadding;
  69195. /**
  69196. * Generates a glb file from the json and binary data
  69197. * Returns an object with the glb file name as the key and data as the value
  69198. * @param glTFPrefix
  69199. * @returns object with glb filename as key and data as value
  69200. */
  69201. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69202. /**
  69203. * Sets the TRS for each node
  69204. * @param node glTF Node for storing the transformation data
  69205. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69206. */
  69207. private setNodeTransformation;
  69208. private getVertexBufferFromMesh;
  69209. /**
  69210. * Creates a bufferview based on the vertices type for the Babylon mesh
  69211. * @param kind Indicates the type of vertices data
  69212. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69213. * @param binaryWriter The buffer to write the bufferview data to
  69214. */
  69215. private createBufferViewKind;
  69216. /**
  69217. * The primitive mode of the Babylon mesh
  69218. * @param babylonMesh The BabylonJS mesh
  69219. */
  69220. private getMeshPrimitiveMode;
  69221. /**
  69222. * Sets the primitive mode of the glTF mesh primitive
  69223. * @param meshPrimitive glTF mesh primitive
  69224. * @param primitiveMode The primitive mode
  69225. */
  69226. private setPrimitiveMode;
  69227. /**
  69228. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69229. * @param meshPrimitive glTF mesh primitive
  69230. * @param attributeKind vertex attribute
  69231. * @returns boolean specifying if uv coordinates are present
  69232. */
  69233. private setAttributeKind;
  69234. /**
  69235. * Sets data for the primitive attributes of each submesh
  69236. * @param mesh glTF Mesh object to store the primitive attribute information
  69237. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69238. * @param binaryWriter Buffer to write the attribute data to
  69239. */
  69240. private setPrimitiveAttributesAsync;
  69241. /**
  69242. * Creates a glTF scene based on the array of meshes
  69243. * Returns the the total byte offset
  69244. * @param babylonScene Babylon scene to get the mesh data from
  69245. * @param binaryWriter Buffer to write binary data to
  69246. */
  69247. private createSceneAsync;
  69248. /**
  69249. * Creates a mapping of Node unique id to node index and handles animations
  69250. * @param babylonScene Babylon Scene
  69251. * @param nodes Babylon transform nodes
  69252. * @param binaryWriter Buffer to write binary data to
  69253. * @returns Node mapping of unique id to index
  69254. */
  69255. private createNodeMapAndAnimationsAsync;
  69256. /**
  69257. * Creates a glTF node from a Babylon mesh
  69258. * @param babylonMesh Source Babylon mesh
  69259. * @param binaryWriter Buffer for storing geometry data
  69260. * @returns glTF node
  69261. */
  69262. private createNodeAsync;
  69263. }
  69264. /**
  69265. * @hidden
  69266. *
  69267. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69268. */
  69269. export class _BinaryWriter {
  69270. /**
  69271. * Array buffer which stores all binary data
  69272. */
  69273. private _arrayBuffer;
  69274. /**
  69275. * View of the array buffer
  69276. */
  69277. private _dataView;
  69278. /**
  69279. * byte offset of data in array buffer
  69280. */
  69281. private _byteOffset;
  69282. /**
  69283. * Initialize binary writer with an initial byte length
  69284. * @param byteLength Initial byte length of the array buffer
  69285. */
  69286. constructor(byteLength: number);
  69287. /**
  69288. * Resize the array buffer to the specified byte length
  69289. * @param byteLength
  69290. */
  69291. private resizeBuffer;
  69292. /**
  69293. * Get an array buffer with the length of the byte offset
  69294. * @returns ArrayBuffer resized to the byte offset
  69295. */
  69296. getArrayBuffer(): ArrayBuffer;
  69297. /**
  69298. * Get the byte offset of the array buffer
  69299. * @returns byte offset
  69300. */
  69301. getByteOffset(): number;
  69302. /**
  69303. * Stores an UInt8 in the array buffer
  69304. * @param entry
  69305. * @param byteOffset If defined, specifies where to set the value as an offset.
  69306. */
  69307. setUInt8(entry: number, byteOffset?: number): void;
  69308. /**
  69309. * Gets an UInt32 in the array buffer
  69310. * @param entry
  69311. * @param byteOffset If defined, specifies where to set the value as an offset.
  69312. */
  69313. getUInt32(byteOffset: number): number;
  69314. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69315. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69316. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69317. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69318. /**
  69319. * Stores a Float32 in the array buffer
  69320. * @param entry
  69321. */
  69322. setFloat32(entry: number, byteOffset?: number): void;
  69323. /**
  69324. * Stores an UInt32 in the array buffer
  69325. * @param entry
  69326. * @param byteOffset If defined, specifies where to set the value as an offset.
  69327. */
  69328. setUInt32(entry: number, byteOffset?: number): void;
  69329. }
  69330. }
  69331. declare module BABYLON.GLTF2.Exporter {
  69332. /**
  69333. * @hidden
  69334. * Interface to store animation data.
  69335. */
  69336. export interface _IAnimationData {
  69337. /**
  69338. * Keyframe data.
  69339. */
  69340. inputs: number[];
  69341. /**
  69342. * Value data.
  69343. */
  69344. outputs: number[][];
  69345. /**
  69346. * Animation interpolation data.
  69347. */
  69348. samplerInterpolation: AnimationSamplerInterpolation;
  69349. /**
  69350. * Minimum keyframe value.
  69351. */
  69352. inputsMin: number;
  69353. /**
  69354. * Maximum keyframe value.
  69355. */
  69356. inputsMax: number;
  69357. }
  69358. /**
  69359. * @hidden
  69360. */
  69361. export interface _IAnimationInfo {
  69362. /**
  69363. * The target channel for the animation
  69364. */
  69365. animationChannelTargetPath: AnimationChannelTargetPath;
  69366. /**
  69367. * The glTF accessor type for the data.
  69368. */
  69369. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69370. /**
  69371. * Specifies if quaternions should be used.
  69372. */
  69373. useQuaternion: boolean;
  69374. }
  69375. /**
  69376. * @hidden
  69377. * Utility class for generating glTF animation data from BabylonJS.
  69378. */
  69379. export class _GLTFAnimation {
  69380. /**
  69381. * @ignore
  69382. *
  69383. * Creates glTF channel animation from BabylonJS animation.
  69384. * @param babylonTransformNode - BabylonJS mesh.
  69385. * @param animation - animation.
  69386. * @param animationChannelTargetPath - The target animation channel.
  69387. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69388. * @param useQuaternion - Specifies if quaternions are used.
  69389. * @returns nullable IAnimationData
  69390. */
  69391. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69392. private static _DeduceAnimationInfo;
  69393. /**
  69394. * @ignore
  69395. * Create node animations from the transform node animations
  69396. * @param babylonNode
  69397. * @param runtimeGLTFAnimation
  69398. * @param idleGLTFAnimations
  69399. * @param nodeMap
  69400. * @param nodes
  69401. * @param binaryWriter
  69402. * @param bufferViews
  69403. * @param accessors
  69404. * @param convertToRightHandedSystem
  69405. */
  69406. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69407. [key: number]: number;
  69408. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69409. /**
  69410. * @ignore
  69411. * Create node animations from the animation groups
  69412. * @param babylonScene
  69413. * @param glTFAnimations
  69414. * @param nodeMap
  69415. * @param nodes
  69416. * @param binaryWriter
  69417. * @param bufferViews
  69418. * @param accessors
  69419. * @param convertToRightHandedSystem
  69420. */
  69421. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69422. [key: number]: number;
  69423. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69424. private static AddAnimation;
  69425. /**
  69426. * Create a baked animation
  69427. * @param babylonTransformNode BabylonJS mesh
  69428. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69429. * @param animationChannelTargetPath animation target channel
  69430. * @param minFrame minimum animation frame
  69431. * @param maxFrame maximum animation frame
  69432. * @param fps frames per second of the animation
  69433. * @param inputs input key frames of the animation
  69434. * @param outputs output key frame data of the animation
  69435. * @param convertToRightHandedSystem converts the values to right-handed
  69436. * @param useQuaternion specifies if quaternions should be used
  69437. */
  69438. private static _CreateBakedAnimation;
  69439. private static _ConvertFactorToVector3OrQuaternion;
  69440. private static _SetInterpolatedValue;
  69441. /**
  69442. * Creates linear animation from the animation key frames
  69443. * @param babylonTransformNode BabylonJS mesh
  69444. * @param animation BabylonJS animation
  69445. * @param animationChannelTargetPath The target animation channel
  69446. * @param frameDelta The difference between the last and first frame of the animation
  69447. * @param inputs Array to store the key frame times
  69448. * @param outputs Array to store the key frame data
  69449. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69450. * @param useQuaternion Specifies if quaternions are used in the animation
  69451. */
  69452. private static _CreateLinearOrStepAnimation;
  69453. /**
  69454. * Creates cubic spline animation from the animation key frames
  69455. * @param babylonTransformNode BabylonJS mesh
  69456. * @param animation BabylonJS animation
  69457. * @param animationChannelTargetPath The target animation channel
  69458. * @param frameDelta The difference between the last and first frame of the animation
  69459. * @param inputs Array to store the key frame times
  69460. * @param outputs Array to store the key frame data
  69461. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69462. * @param useQuaternion Specifies if quaternions are used in the animation
  69463. */
  69464. private static _CreateCubicSplineAnimation;
  69465. private static _GetBasePositionRotationOrScale;
  69466. /**
  69467. * Adds a key frame value
  69468. * @param keyFrame
  69469. * @param animation
  69470. * @param outputs
  69471. * @param animationChannelTargetPath
  69472. * @param basePositionRotationOrScale
  69473. * @param convertToRightHandedSystem
  69474. * @param useQuaternion
  69475. */
  69476. private static _AddKeyframeValue;
  69477. /**
  69478. * Determine the interpolation based on the key frames
  69479. * @param keyFrames
  69480. * @param animationChannelTargetPath
  69481. * @param useQuaternion
  69482. */
  69483. private static _DeduceInterpolation;
  69484. /**
  69485. * Adds an input tangent or output tangent to the output data
  69486. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69487. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69488. * @param outputs The animation data by keyframe
  69489. * @param animationChannelTargetPath The target animation channel
  69490. * @param interpolation The interpolation type
  69491. * @param keyFrame The key frame with the animation data
  69492. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69493. * @param useQuaternion Specifies if quaternions are used
  69494. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69495. */
  69496. private static AddSplineTangent;
  69497. /**
  69498. * Get the minimum and maximum key frames' frame values
  69499. * @param keyFrames animation key frames
  69500. * @returns the minimum and maximum key frame value
  69501. */
  69502. private static calculateMinMaxKeyFrames;
  69503. }
  69504. }
  69505. declare module BABYLON.GLTF2.Exporter {
  69506. /** @hidden */
  69507. export var textureTransformPixelShader: {
  69508. name: string;
  69509. shader: string;
  69510. };
  69511. }
  69512. declare module BABYLON.GLTF2.Exporter.Extensions {
  69513. /**
  69514. * @hidden
  69515. */
  69516. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69517. /** Name of this extension */
  69518. readonly name: string;
  69519. /** Defines whether this extension is enabled */
  69520. enabled: boolean;
  69521. /** Defines whether this extension is required */
  69522. required: boolean;
  69523. /** Reference to the glTF exporter */
  69524. private _exporter;
  69525. constructor(exporter: _Exporter);
  69526. dispose(): void;
  69527. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69528. /**
  69529. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69530. * @param babylonTexture
  69531. * @param offset
  69532. * @param rotation
  69533. * @param scale
  69534. * @param scene
  69535. */
  69536. private _textureTransformTextureAsync;
  69537. }
  69538. }
  69539. declare module BABYLON.GLTF2.Exporter.Extensions {
  69540. /**
  69541. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69542. */
  69543. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69544. /** The name of this extension. */
  69545. readonly name: string;
  69546. /** Defines whether this extension is enabled. */
  69547. enabled: boolean;
  69548. /** Defines whether this extension is required */
  69549. required: boolean;
  69550. /** Reference to the glTF exporter */
  69551. private _exporter;
  69552. private _lights;
  69553. /** @hidden */
  69554. constructor(exporter: _Exporter);
  69555. /** @hidden */
  69556. dispose(): void;
  69557. /** @hidden */
  69558. onExporting(): void;
  69559. /**
  69560. * Define this method to modify the default behavior when exporting a node
  69561. * @param context The context when exporting the node
  69562. * @param node glTF node
  69563. * @param babylonNode BabylonJS node
  69564. * @returns nullable INode promise
  69565. */
  69566. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69567. }
  69568. }
  69569. declare module BABYLON {
  69570. /**
  69571. * Class for generating STL data from a Babylon scene.
  69572. */
  69573. export class STLExport {
  69574. /**
  69575. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69576. * @param meshes list defines the mesh to serialize
  69577. * @param download triggers the automatic download of the file.
  69578. * @param fileName changes the downloads fileName.
  69579. * @param binary changes the STL to a binary type.
  69580. * @param isLittleEndian toggle for binary type exporter.
  69581. * @returns the STL as UTF8 string
  69582. */
  69583. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69584. }
  69585. }
  69586. /**
  69587. * @ignoreChildren
  69588. * @ignore
  69589. */
  69590. declare module "babylonjs-gltf2interface" {
  69591. export = BABYLON.GLTF2;
  69592. }
  69593. /**
  69594. * Module for glTF 2.0 Interface
  69595. * @ignoreChildren
  69596. * @ignore
  69597. */
  69598. declare module BABYLON.GLTF2 {
  69599. /**
  69600. * The datatype of the components in the attribute
  69601. */
  69602. const enum AccessorComponentType {
  69603. /**
  69604. * Byte
  69605. */
  69606. BYTE = 5120,
  69607. /**
  69608. * Unsigned Byte
  69609. */
  69610. UNSIGNED_BYTE = 5121,
  69611. /**
  69612. * Short
  69613. */
  69614. SHORT = 5122,
  69615. /**
  69616. * Unsigned Short
  69617. */
  69618. UNSIGNED_SHORT = 5123,
  69619. /**
  69620. * Unsigned Int
  69621. */
  69622. UNSIGNED_INT = 5125,
  69623. /**
  69624. * Float
  69625. */
  69626. FLOAT = 5126,
  69627. }
  69628. /**
  69629. * Specifies if the attirbute is a scalar, vector, or matrix
  69630. */
  69631. const enum AccessorType {
  69632. /**
  69633. * Scalar
  69634. */
  69635. SCALAR = "SCALAR",
  69636. /**
  69637. * Vector2
  69638. */
  69639. VEC2 = "VEC2",
  69640. /**
  69641. * Vector3
  69642. */
  69643. VEC3 = "VEC3",
  69644. /**
  69645. * Vector4
  69646. */
  69647. VEC4 = "VEC4",
  69648. /**
  69649. * Matrix2x2
  69650. */
  69651. MAT2 = "MAT2",
  69652. /**
  69653. * Matrix3x3
  69654. */
  69655. MAT3 = "MAT3",
  69656. /**
  69657. * Matrix4x4
  69658. */
  69659. MAT4 = "MAT4",
  69660. }
  69661. /**
  69662. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69663. */
  69664. const enum AnimationChannelTargetPath {
  69665. /**
  69666. * Translation
  69667. */
  69668. TRANSLATION = "translation",
  69669. /**
  69670. * Rotation
  69671. */
  69672. ROTATION = "rotation",
  69673. /**
  69674. * Scale
  69675. */
  69676. SCALE = "scale",
  69677. /**
  69678. * Weights
  69679. */
  69680. WEIGHTS = "weights",
  69681. }
  69682. /**
  69683. * Interpolation algorithm
  69684. */
  69685. const enum AnimationSamplerInterpolation {
  69686. /**
  69687. * The animated values are linearly interpolated between keyframes
  69688. */
  69689. LINEAR = "LINEAR",
  69690. /**
  69691. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69692. */
  69693. STEP = "STEP",
  69694. /**
  69695. * The animation's interpolation is computed using a cubic spline with specified tangents
  69696. */
  69697. CUBICSPLINE = "CUBICSPLINE",
  69698. }
  69699. /**
  69700. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69701. */
  69702. const enum CameraType {
  69703. /**
  69704. * A perspective camera containing properties to create a perspective projection matrix
  69705. */
  69706. PERSPECTIVE = "perspective",
  69707. /**
  69708. * An orthographic camera containing properties to create an orthographic projection matrix
  69709. */
  69710. ORTHOGRAPHIC = "orthographic",
  69711. }
  69712. /**
  69713. * The mime-type of the image
  69714. */
  69715. const enum ImageMimeType {
  69716. /**
  69717. * JPEG Mime-type
  69718. */
  69719. JPEG = "image/jpeg",
  69720. /**
  69721. * PNG Mime-type
  69722. */
  69723. PNG = "image/png",
  69724. }
  69725. /**
  69726. * The alpha rendering mode of the material
  69727. */
  69728. const enum MaterialAlphaMode {
  69729. /**
  69730. * The alpha value is ignored and the rendered output is fully opaque
  69731. */
  69732. OPAQUE = "OPAQUE",
  69733. /**
  69734. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69735. */
  69736. MASK = "MASK",
  69737. /**
  69738. * 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)
  69739. */
  69740. BLEND = "BLEND",
  69741. }
  69742. /**
  69743. * The type of the primitives to render
  69744. */
  69745. const enum MeshPrimitiveMode {
  69746. /**
  69747. * Points
  69748. */
  69749. POINTS = 0,
  69750. /**
  69751. * Lines
  69752. */
  69753. LINES = 1,
  69754. /**
  69755. * Line Loop
  69756. */
  69757. LINE_LOOP = 2,
  69758. /**
  69759. * Line Strip
  69760. */
  69761. LINE_STRIP = 3,
  69762. /**
  69763. * Triangles
  69764. */
  69765. TRIANGLES = 4,
  69766. /**
  69767. * Triangle Strip
  69768. */
  69769. TRIANGLE_STRIP = 5,
  69770. /**
  69771. * Triangle Fan
  69772. */
  69773. TRIANGLE_FAN = 6,
  69774. }
  69775. /**
  69776. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69777. */
  69778. const enum TextureMagFilter {
  69779. /**
  69780. * Nearest
  69781. */
  69782. NEAREST = 9728,
  69783. /**
  69784. * Linear
  69785. */
  69786. LINEAR = 9729,
  69787. }
  69788. /**
  69789. * Minification filter. All valid values correspond to WebGL enums
  69790. */
  69791. const enum TextureMinFilter {
  69792. /**
  69793. * Nearest
  69794. */
  69795. NEAREST = 9728,
  69796. /**
  69797. * Linear
  69798. */
  69799. LINEAR = 9729,
  69800. /**
  69801. * Nearest Mip-Map Nearest
  69802. */
  69803. NEAREST_MIPMAP_NEAREST = 9984,
  69804. /**
  69805. * Linear Mipmap Nearest
  69806. */
  69807. LINEAR_MIPMAP_NEAREST = 9985,
  69808. /**
  69809. * Nearest Mipmap Linear
  69810. */
  69811. NEAREST_MIPMAP_LINEAR = 9986,
  69812. /**
  69813. * Linear Mipmap Linear
  69814. */
  69815. LINEAR_MIPMAP_LINEAR = 9987,
  69816. }
  69817. /**
  69818. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69819. */
  69820. const enum TextureWrapMode {
  69821. /**
  69822. * Clamp to Edge
  69823. */
  69824. CLAMP_TO_EDGE = 33071,
  69825. /**
  69826. * Mirrored Repeat
  69827. */
  69828. MIRRORED_REPEAT = 33648,
  69829. /**
  69830. * Repeat
  69831. */
  69832. REPEAT = 10497,
  69833. }
  69834. /**
  69835. * glTF Property
  69836. */
  69837. interface IProperty {
  69838. /**
  69839. * Dictionary object with extension-specific objects
  69840. */
  69841. extensions?: {
  69842. [key: string]: any;
  69843. };
  69844. /**
  69845. * Application-Specific data
  69846. */
  69847. extras?: any;
  69848. }
  69849. /**
  69850. * glTF Child of Root Property
  69851. */
  69852. interface IChildRootProperty extends IProperty {
  69853. /**
  69854. * The user-defined name of this object
  69855. */
  69856. name?: string;
  69857. }
  69858. /**
  69859. * Indices of those attributes that deviate from their initialization value
  69860. */
  69861. interface IAccessorSparseIndices extends IProperty {
  69862. /**
  69863. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69864. */
  69865. bufferView: number;
  69866. /**
  69867. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69868. */
  69869. byteOffset?: number;
  69870. /**
  69871. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69872. */
  69873. componentType: AccessorComponentType;
  69874. }
  69875. /**
  69876. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69877. */
  69878. interface IAccessorSparseValues extends IProperty {
  69879. /**
  69880. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69881. */
  69882. bufferView: number;
  69883. /**
  69884. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69885. */
  69886. byteOffset?: number;
  69887. }
  69888. /**
  69889. * Sparse storage of attributes that deviate from their initialization value
  69890. */
  69891. interface IAccessorSparse extends IProperty {
  69892. /**
  69893. * The number of attributes encoded in this sparse accessor
  69894. */
  69895. count: number;
  69896. /**
  69897. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69898. */
  69899. indices: IAccessorSparseIndices;
  69900. /**
  69901. * 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
  69902. */
  69903. values: IAccessorSparseValues;
  69904. }
  69905. /**
  69906. * 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
  69907. */
  69908. interface IAccessor extends IChildRootProperty {
  69909. /**
  69910. * The index of the bufferview
  69911. */
  69912. bufferView?: number;
  69913. /**
  69914. * The offset relative to the start of the bufferView in bytes
  69915. */
  69916. byteOffset?: number;
  69917. /**
  69918. * The datatype of components in the attribute
  69919. */
  69920. componentType: AccessorComponentType;
  69921. /**
  69922. * Specifies whether integer data values should be normalized
  69923. */
  69924. normalized?: boolean;
  69925. /**
  69926. * The number of attributes referenced by this accessor
  69927. */
  69928. count: number;
  69929. /**
  69930. * Specifies if the attribute is a scalar, vector, or matrix
  69931. */
  69932. type: AccessorType;
  69933. /**
  69934. * Maximum value of each component in this attribute
  69935. */
  69936. max?: number[];
  69937. /**
  69938. * Minimum value of each component in this attribute
  69939. */
  69940. min?: number[];
  69941. /**
  69942. * Sparse storage of attributes that deviate from their initialization value
  69943. */
  69944. sparse?: IAccessorSparse;
  69945. }
  69946. /**
  69947. * Targets an animation's sampler at a node's property
  69948. */
  69949. interface IAnimationChannel extends IProperty {
  69950. /**
  69951. * The index of a sampler in this animation used to compute the value for the target
  69952. */
  69953. sampler: number;
  69954. /**
  69955. * The index of the node and TRS property to target
  69956. */
  69957. target: IAnimationChannelTarget;
  69958. }
  69959. /**
  69960. * The index of the node and TRS property that an animation channel targets
  69961. */
  69962. interface IAnimationChannelTarget extends IProperty {
  69963. /**
  69964. * The index of the node to target
  69965. */
  69966. node: number;
  69967. /**
  69968. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69969. */
  69970. path: AnimationChannelTargetPath;
  69971. }
  69972. /**
  69973. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69974. */
  69975. interface IAnimationSampler extends IProperty {
  69976. /**
  69977. * The index of an accessor containing keyframe input values, e.g., time
  69978. */
  69979. input: number;
  69980. /**
  69981. * Interpolation algorithm
  69982. */
  69983. interpolation?: AnimationSamplerInterpolation;
  69984. /**
  69985. * The index of an accessor, containing keyframe output values
  69986. */
  69987. output: number;
  69988. }
  69989. /**
  69990. * A keyframe animation
  69991. */
  69992. interface IAnimation extends IChildRootProperty {
  69993. /**
  69994. * An array of channels, each of which targets an animation's sampler at a node's property
  69995. */
  69996. channels: IAnimationChannel[];
  69997. /**
  69998. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69999. */
  70000. samplers: IAnimationSampler[];
  70001. }
  70002. /**
  70003. * Metadata about the glTF asset
  70004. */
  70005. interface IAsset extends IChildRootProperty {
  70006. /**
  70007. * A copyright message suitable for display to credit the content creator
  70008. */
  70009. copyright?: string;
  70010. /**
  70011. * Tool that generated this glTF model. Useful for debugging
  70012. */
  70013. generator?: string;
  70014. /**
  70015. * The glTF version that this asset targets
  70016. */
  70017. version: string;
  70018. /**
  70019. * The minimum glTF version that this asset targets
  70020. */
  70021. minVersion?: string;
  70022. }
  70023. /**
  70024. * A buffer points to binary geometry, animation, or skins
  70025. */
  70026. interface IBuffer extends IChildRootProperty {
  70027. /**
  70028. * 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
  70029. */
  70030. uri?: string;
  70031. /**
  70032. * The length of the buffer in bytes
  70033. */
  70034. byteLength: number;
  70035. }
  70036. /**
  70037. * A view into a buffer generally representing a subset of the buffer
  70038. */
  70039. interface IBufferView extends IChildRootProperty {
  70040. /**
  70041. * The index of the buffer
  70042. */
  70043. buffer: number;
  70044. /**
  70045. * The offset into the buffer in bytes
  70046. */
  70047. byteOffset?: number;
  70048. /**
  70049. * The lenth of the bufferView in bytes
  70050. */
  70051. byteLength: number;
  70052. /**
  70053. * The stride, in bytes
  70054. */
  70055. byteStride?: number;
  70056. }
  70057. /**
  70058. * An orthographic camera containing properties to create an orthographic projection matrix
  70059. */
  70060. interface ICameraOrthographic extends IProperty {
  70061. /**
  70062. * The floating-point horizontal magnification of the view. Must not be zero
  70063. */
  70064. xmag: number;
  70065. /**
  70066. * The floating-point vertical magnification of the view. Must not be zero
  70067. */
  70068. ymag: number;
  70069. /**
  70070. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70071. */
  70072. zfar: number;
  70073. /**
  70074. * The floating-point distance to the near clipping plane
  70075. */
  70076. znear: number;
  70077. }
  70078. /**
  70079. * A perspective camera containing properties to create a perspective projection matrix
  70080. */
  70081. interface ICameraPerspective extends IProperty {
  70082. /**
  70083. * The floating-point aspect ratio of the field of view
  70084. */
  70085. aspectRatio?: number;
  70086. /**
  70087. * The floating-point vertical field of view in radians
  70088. */
  70089. yfov: number;
  70090. /**
  70091. * The floating-point distance to the far clipping plane
  70092. */
  70093. zfar?: number;
  70094. /**
  70095. * The floating-point distance to the near clipping plane
  70096. */
  70097. znear: number;
  70098. }
  70099. /**
  70100. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70101. */
  70102. interface ICamera extends IChildRootProperty {
  70103. /**
  70104. * An orthographic camera containing properties to create an orthographic projection matrix
  70105. */
  70106. orthographic?: ICameraOrthographic;
  70107. /**
  70108. * A perspective camera containing properties to create a perspective projection matrix
  70109. */
  70110. perspective?: ICameraPerspective;
  70111. /**
  70112. * Specifies if the camera uses a perspective or orthographic projection
  70113. */
  70114. type: CameraType;
  70115. }
  70116. /**
  70117. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70118. */
  70119. interface IImage extends IChildRootProperty {
  70120. /**
  70121. * 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
  70122. */
  70123. uri?: string;
  70124. /**
  70125. * The image's MIME type
  70126. */
  70127. mimeType?: ImageMimeType;
  70128. /**
  70129. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70130. */
  70131. bufferView?: number;
  70132. }
  70133. /**
  70134. * Material Normal Texture Info
  70135. */
  70136. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70137. /**
  70138. * The scalar multiplier applied to each normal vector of the normal texture
  70139. */
  70140. scale?: number;
  70141. }
  70142. /**
  70143. * Material Occlusion Texture Info
  70144. */
  70145. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70146. /**
  70147. * A scalar multiplier controlling the amount of occlusion applied
  70148. */
  70149. strength?: number;
  70150. }
  70151. /**
  70152. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70153. */
  70154. interface IMaterialPbrMetallicRoughness {
  70155. /**
  70156. * The material's base color factor
  70157. */
  70158. baseColorFactor?: number[];
  70159. /**
  70160. * The base color texture
  70161. */
  70162. baseColorTexture?: ITextureInfo;
  70163. /**
  70164. * The metalness of the material
  70165. */
  70166. metallicFactor?: number;
  70167. /**
  70168. * The roughness of the material
  70169. */
  70170. roughnessFactor?: number;
  70171. /**
  70172. * The metallic-roughness texture
  70173. */
  70174. metallicRoughnessTexture?: ITextureInfo;
  70175. }
  70176. /**
  70177. * The material appearance of a primitive
  70178. */
  70179. interface IMaterial extends IChildRootProperty {
  70180. /**
  70181. * 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
  70182. */
  70183. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70184. /**
  70185. * The normal map texture
  70186. */
  70187. normalTexture?: IMaterialNormalTextureInfo;
  70188. /**
  70189. * The occlusion map texture
  70190. */
  70191. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70192. /**
  70193. * The emissive map texture
  70194. */
  70195. emissiveTexture?: ITextureInfo;
  70196. /**
  70197. * 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
  70198. */
  70199. emissiveFactor?: number[];
  70200. /**
  70201. * The alpha rendering mode of the material
  70202. */
  70203. alphaMode?: MaterialAlphaMode;
  70204. /**
  70205. * The alpha cutoff value of the material
  70206. */
  70207. alphaCutoff?: number;
  70208. /**
  70209. * Specifies whether the material is double sided
  70210. */
  70211. doubleSided?: boolean;
  70212. }
  70213. /**
  70214. * Geometry to be rendered with the given material
  70215. */
  70216. interface IMeshPrimitive extends IProperty {
  70217. /**
  70218. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70219. */
  70220. attributes: {
  70221. [name: string]: number;
  70222. };
  70223. /**
  70224. * The index of the accessor that contains the indices
  70225. */
  70226. indices?: number;
  70227. /**
  70228. * The index of the material to apply to this primitive when rendering
  70229. */
  70230. material?: number;
  70231. /**
  70232. * The type of primitives to render. All valid values correspond to WebGL enums
  70233. */
  70234. mode?: MeshPrimitiveMode;
  70235. /**
  70236. * 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
  70237. */
  70238. targets?: {
  70239. [name: string]: number;
  70240. }[];
  70241. }
  70242. /**
  70243. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70244. */
  70245. interface IMesh extends IChildRootProperty {
  70246. /**
  70247. * An array of primitives, each defining geometry to be rendered with a material
  70248. */
  70249. primitives: IMeshPrimitive[];
  70250. /**
  70251. * Array of weights to be applied to the Morph Targets
  70252. */
  70253. weights?: number[];
  70254. }
  70255. /**
  70256. * A node in the node hierarchy
  70257. */
  70258. interface INode extends IChildRootProperty {
  70259. /**
  70260. * The index of the camera referenced by this node
  70261. */
  70262. camera?: number;
  70263. /**
  70264. * The indices of this node's children
  70265. */
  70266. children?: number[];
  70267. /**
  70268. * The index of the skin referenced by this node
  70269. */
  70270. skin?: number;
  70271. /**
  70272. * A floating-point 4x4 transformation matrix stored in column-major order
  70273. */
  70274. matrix?: number[];
  70275. /**
  70276. * The index of the mesh in this node
  70277. */
  70278. mesh?: number;
  70279. /**
  70280. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70281. */
  70282. rotation?: number[];
  70283. /**
  70284. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70285. */
  70286. scale?: number[];
  70287. /**
  70288. * The node's translation along the x, y, and z axes
  70289. */
  70290. translation?: number[];
  70291. /**
  70292. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70293. */
  70294. weights?: number[];
  70295. }
  70296. /**
  70297. * Texture sampler properties for filtering and wrapping modes
  70298. */
  70299. interface ISampler extends IChildRootProperty {
  70300. /**
  70301. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70302. */
  70303. magFilter?: TextureMagFilter;
  70304. /**
  70305. * Minification filter. All valid values correspond to WebGL enums
  70306. */
  70307. minFilter?: TextureMinFilter;
  70308. /**
  70309. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70310. */
  70311. wrapS?: TextureWrapMode;
  70312. /**
  70313. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70314. */
  70315. wrapT?: TextureWrapMode;
  70316. }
  70317. /**
  70318. * The root nodes of a scene
  70319. */
  70320. interface IScene extends IChildRootProperty {
  70321. /**
  70322. * The indices of each root node
  70323. */
  70324. nodes: number[];
  70325. }
  70326. /**
  70327. * Joints and matrices defining a skin
  70328. */
  70329. interface ISkin extends IChildRootProperty {
  70330. /**
  70331. * 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
  70332. */
  70333. inverseBindMatrices?: number;
  70334. /**
  70335. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70336. */
  70337. skeleton?: number;
  70338. /**
  70339. * 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)
  70340. */
  70341. joints: number[];
  70342. }
  70343. /**
  70344. * A texture and its sampler
  70345. */
  70346. interface ITexture extends IChildRootProperty {
  70347. /**
  70348. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70349. */
  70350. sampler?: number;
  70351. /**
  70352. * The index of the image used by this texture
  70353. */
  70354. source: number;
  70355. }
  70356. /**
  70357. * Reference to a texture
  70358. */
  70359. interface ITextureInfo extends IProperty {
  70360. /**
  70361. * The index of the texture
  70362. */
  70363. index: number;
  70364. /**
  70365. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70366. */
  70367. texCoord?: number;
  70368. }
  70369. /**
  70370. * The root object for a glTF asset
  70371. */
  70372. interface IGLTF extends IProperty {
  70373. /**
  70374. * An array of accessors. An accessor is a typed view into a bufferView
  70375. */
  70376. accessors?: IAccessor[];
  70377. /**
  70378. * An array of keyframe animations
  70379. */
  70380. animations?: IAnimation[];
  70381. /**
  70382. * Metadata about the glTF asset
  70383. */
  70384. asset: IAsset;
  70385. /**
  70386. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70387. */
  70388. buffers?: IBuffer[];
  70389. /**
  70390. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70391. */
  70392. bufferViews?: IBufferView[];
  70393. /**
  70394. * An array of cameras
  70395. */
  70396. cameras?: ICamera[];
  70397. /**
  70398. * Names of glTF extensions used somewhere in this asset
  70399. */
  70400. extensionsUsed?: string[];
  70401. /**
  70402. * Names of glTF extensions required to properly load this asset
  70403. */
  70404. extensionsRequired?: string[];
  70405. /**
  70406. * An array of images. An image defines data used to create a texture
  70407. */
  70408. images?: IImage[];
  70409. /**
  70410. * An array of materials. A material defines the appearance of a primitive
  70411. */
  70412. materials?: IMaterial[];
  70413. /**
  70414. * An array of meshes. A mesh is a set of primitives to be rendered
  70415. */
  70416. meshes?: IMesh[];
  70417. /**
  70418. * An array of nodes
  70419. */
  70420. nodes?: INode[];
  70421. /**
  70422. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70423. */
  70424. samplers?: ISampler[];
  70425. /**
  70426. * The index of the default scene
  70427. */
  70428. scene?: number;
  70429. /**
  70430. * An array of scenes
  70431. */
  70432. scenes?: IScene[];
  70433. /**
  70434. * An array of skins. A skin is defined by joints and matrices
  70435. */
  70436. skins?: ISkin[];
  70437. /**
  70438. * An array of textures
  70439. */
  70440. textures?: ITexture[];
  70441. }
  70442. /**
  70443. * The glTF validation results
  70444. */
  70445. interface IGLTFValidationResults {
  70446. info: {
  70447. generator: string;
  70448. hasAnimations: boolean;
  70449. hasDefaultScene: boolean;
  70450. hasMaterials: boolean;
  70451. hasMorphTargets: boolean;
  70452. hasSkins: boolean;
  70453. hasTextures: boolean;
  70454. maxAttributesUsed: number;
  70455. primitivesCount: number
  70456. };
  70457. issues: {
  70458. messages: Array<string>;
  70459. numErrors: number;
  70460. numHints: number;
  70461. numInfos: number;
  70462. numWarnings: number;
  70463. truncated: boolean
  70464. };
  70465. mimeType: string;
  70466. uri: string;
  70467. validatedAt: string;
  70468. validatorVersion: string;
  70469. }
  70470. /**
  70471. * The glTF validation options
  70472. */
  70473. interface IGLTFValidationOptions {
  70474. uri?: string;
  70475. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70476. validateAccessorData?: boolean;
  70477. maxIssues?: number;
  70478. ignoredIssues?: Array<string>;
  70479. severityOverrides?: Object;
  70480. }
  70481. /**
  70482. * The glTF validator object
  70483. */
  70484. interface IGLTFValidator {
  70485. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70486. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70487. }
  70488. }
  70489. declare module BABYLON {
  70490. /** @hidden */
  70491. export var cellPixelShader: {
  70492. name: string;
  70493. shader: string;
  70494. };
  70495. }
  70496. declare module BABYLON {
  70497. /** @hidden */
  70498. export var cellVertexShader: {
  70499. name: string;
  70500. shader: string;
  70501. };
  70502. }
  70503. declare module BABYLON {
  70504. export class CellMaterial extends BABYLON.PushMaterial {
  70505. private _diffuseTexture;
  70506. diffuseTexture: BABYLON.BaseTexture;
  70507. diffuseColor: BABYLON.Color3;
  70508. _computeHighLevel: boolean;
  70509. computeHighLevel: boolean;
  70510. private _disableLighting;
  70511. disableLighting: boolean;
  70512. private _maxSimultaneousLights;
  70513. maxSimultaneousLights: number;
  70514. private _renderId;
  70515. constructor(name: string, scene: BABYLON.Scene);
  70516. needAlphaBlending(): boolean;
  70517. needAlphaTesting(): boolean;
  70518. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70519. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70520. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70521. getAnimatables(): BABYLON.IAnimatable[];
  70522. getActiveTextures(): BABYLON.BaseTexture[];
  70523. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70524. dispose(forceDisposeEffect?: boolean): void;
  70525. getClassName(): string;
  70526. clone(name: string): CellMaterial;
  70527. serialize(): any;
  70528. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70529. }
  70530. }
  70531. declare module BABYLON {
  70532. export class CustomShaderStructure {
  70533. FragmentStore: string;
  70534. VertexStore: string;
  70535. constructor();
  70536. }
  70537. export class ShaderSpecialParts {
  70538. constructor();
  70539. Fragment_Begin: string;
  70540. Fragment_Definitions: string;
  70541. Fragment_MainBegin: string;
  70542. Fragment_Custom_Diffuse: string;
  70543. Fragment_Before_Lights: string;
  70544. Fragment_Before_Fog: string;
  70545. Fragment_Custom_Alpha: string;
  70546. Fragment_Before_FragColor: string;
  70547. Vertex_Begin: string;
  70548. Vertex_Definitions: string;
  70549. Vertex_MainBegin: string;
  70550. Vertex_Before_PositionUpdated: string;
  70551. Vertex_Before_NormalUpdated: string;
  70552. Vertex_MainEnd: string;
  70553. }
  70554. export class CustomMaterial extends BABYLON.StandardMaterial {
  70555. static ShaderIndexer: number;
  70556. CustomParts: ShaderSpecialParts;
  70557. _isCreatedShader: boolean;
  70558. _createdShaderName: string;
  70559. _customUniform: string[];
  70560. _newUniforms: string[];
  70561. _newUniformInstances: any[];
  70562. _newSamplerInstances: BABYLON.Texture[];
  70563. FragmentShader: string;
  70564. VertexShader: string;
  70565. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70566. ReviewUniform(name: string, arr: string[]): string[];
  70567. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70568. constructor(name: string, scene: BABYLON.Scene);
  70569. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70570. Fragment_Begin(shaderPart: string): CustomMaterial;
  70571. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70572. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70573. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70574. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70575. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70576. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70577. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70578. Vertex_Begin(shaderPart: string): CustomMaterial;
  70579. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70580. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70581. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70582. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70583. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70584. }
  70585. }
  70586. declare module BABYLON {
  70587. export class ShaderAlebdoParts {
  70588. constructor();
  70589. Fragment_Begin: string;
  70590. Fragment_Definitions: string;
  70591. Fragment_MainBegin: string;
  70592. Fragment_Custom_Albedo: string;
  70593. Fragment_Before_Lights: string;
  70594. Fragment_Custom_MetallicRoughness: string;
  70595. Fragment_Custom_MicroSurface: string;
  70596. Fragment_Before_Fog: string;
  70597. Fragment_Custom_Alpha: string;
  70598. Fragment_Before_FragColor: string;
  70599. Vertex_Begin: string;
  70600. Vertex_Definitions: string;
  70601. Vertex_MainBegin: string;
  70602. Vertex_Before_PositionUpdated: string;
  70603. Vertex_Before_NormalUpdated: string;
  70604. Vertex_MainEnd: string;
  70605. }
  70606. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70607. static ShaderIndexer: number;
  70608. CustomParts: ShaderAlebdoParts;
  70609. _isCreatedShader: boolean;
  70610. _createdShaderName: string;
  70611. _customUniform: string[];
  70612. _newUniforms: string[];
  70613. _newUniformInstances: any[];
  70614. _newSamplerInstances: BABYLON.Texture[];
  70615. FragmentShader: string;
  70616. VertexShader: string;
  70617. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70618. ReviewUniform(name: string, arr: string[]): string[];
  70619. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70620. constructor(name: string, scene: BABYLON.Scene);
  70621. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70622. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70623. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70624. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70625. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70626. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70627. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70628. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70629. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70630. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70631. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70632. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70633. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70634. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70635. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70636. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70637. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70638. }
  70639. }
  70640. declare module BABYLON {
  70641. /** @hidden */
  70642. export var firePixelShader: {
  70643. name: string;
  70644. shader: string;
  70645. };
  70646. }
  70647. declare module BABYLON {
  70648. /** @hidden */
  70649. export var fireVertexShader: {
  70650. name: string;
  70651. shader: string;
  70652. };
  70653. }
  70654. declare module BABYLON {
  70655. export class FireMaterial extends BABYLON.PushMaterial {
  70656. private _diffuseTexture;
  70657. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70658. private _distortionTexture;
  70659. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70660. private _opacityTexture;
  70661. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70662. diffuseColor: BABYLON.Color3;
  70663. speed: number;
  70664. private _scaledDiffuse;
  70665. private _renderId;
  70666. private _lastTime;
  70667. constructor(name: string, scene: BABYLON.Scene);
  70668. needAlphaBlending(): boolean;
  70669. needAlphaTesting(): boolean;
  70670. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70671. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70672. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70673. getAnimatables(): BABYLON.IAnimatable[];
  70674. getActiveTextures(): BABYLON.BaseTexture[];
  70675. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70676. getClassName(): string;
  70677. dispose(forceDisposeEffect?: boolean): void;
  70678. clone(name: string): FireMaterial;
  70679. serialize(): any;
  70680. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70681. }
  70682. }
  70683. declare module BABYLON {
  70684. /** @hidden */
  70685. export var furPixelShader: {
  70686. name: string;
  70687. shader: string;
  70688. };
  70689. }
  70690. declare module BABYLON {
  70691. /** @hidden */
  70692. export var furVertexShader: {
  70693. name: string;
  70694. shader: string;
  70695. };
  70696. }
  70697. declare module BABYLON {
  70698. export class FurMaterial extends BABYLON.PushMaterial {
  70699. private _diffuseTexture;
  70700. diffuseTexture: BABYLON.BaseTexture;
  70701. private _heightTexture;
  70702. heightTexture: BABYLON.BaseTexture;
  70703. diffuseColor: BABYLON.Color3;
  70704. furLength: number;
  70705. furAngle: number;
  70706. furColor: BABYLON.Color3;
  70707. furOffset: number;
  70708. furSpacing: number;
  70709. furGravity: BABYLON.Vector3;
  70710. furSpeed: number;
  70711. furDensity: number;
  70712. furOcclusion: number;
  70713. furTexture: BABYLON.DynamicTexture;
  70714. private _disableLighting;
  70715. disableLighting: boolean;
  70716. private _maxSimultaneousLights;
  70717. maxSimultaneousLights: number;
  70718. highLevelFur: boolean;
  70719. _meshes: BABYLON.AbstractMesh[];
  70720. private _renderId;
  70721. private _furTime;
  70722. constructor(name: string, scene: BABYLON.Scene);
  70723. furTime: number;
  70724. needAlphaBlending(): boolean;
  70725. needAlphaTesting(): boolean;
  70726. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70727. updateFur(): void;
  70728. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70729. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70730. getAnimatables(): BABYLON.IAnimatable[];
  70731. getActiveTextures(): BABYLON.BaseTexture[];
  70732. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70733. dispose(forceDisposeEffect?: boolean): void;
  70734. clone(name: string): FurMaterial;
  70735. serialize(): any;
  70736. getClassName(): string;
  70737. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70738. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70739. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70740. }
  70741. }
  70742. declare module BABYLON {
  70743. /** @hidden */
  70744. export var gradientPixelShader: {
  70745. name: string;
  70746. shader: string;
  70747. };
  70748. }
  70749. declare module BABYLON {
  70750. /** @hidden */
  70751. export var gradientVertexShader: {
  70752. name: string;
  70753. shader: string;
  70754. };
  70755. }
  70756. declare module BABYLON {
  70757. export class GradientMaterial extends BABYLON.PushMaterial {
  70758. private _maxSimultaneousLights;
  70759. maxSimultaneousLights: number;
  70760. topColor: BABYLON.Color3;
  70761. topColorAlpha: number;
  70762. bottomColor: BABYLON.Color3;
  70763. bottomColorAlpha: number;
  70764. offset: number;
  70765. scale: number;
  70766. smoothness: number;
  70767. private _disableLighting;
  70768. disableLighting: boolean;
  70769. private _renderId;
  70770. constructor(name: string, scene: BABYLON.Scene);
  70771. needAlphaBlending(): boolean;
  70772. needAlphaTesting(): boolean;
  70773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70774. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70775. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70776. getAnimatables(): BABYLON.IAnimatable[];
  70777. dispose(forceDisposeEffect?: boolean): void;
  70778. clone(name: string): GradientMaterial;
  70779. serialize(): any;
  70780. getClassName(): string;
  70781. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70782. }
  70783. }
  70784. declare module BABYLON {
  70785. /** @hidden */
  70786. export var gridPixelShader: {
  70787. name: string;
  70788. shader: string;
  70789. };
  70790. }
  70791. declare module BABYLON {
  70792. /** @hidden */
  70793. export var gridVertexShader: {
  70794. name: string;
  70795. shader: string;
  70796. };
  70797. }
  70798. declare module BABYLON {
  70799. /**
  70800. * The grid materials allows you to wrap any shape with a grid.
  70801. * Colors are customizable.
  70802. */
  70803. export class GridMaterial extends BABYLON.PushMaterial {
  70804. /**
  70805. * Main color of the grid (e.g. between lines)
  70806. */
  70807. mainColor: BABYLON.Color3;
  70808. /**
  70809. * Color of the grid lines.
  70810. */
  70811. lineColor: BABYLON.Color3;
  70812. /**
  70813. * The scale of the grid compared to unit.
  70814. */
  70815. gridRatio: number;
  70816. /**
  70817. * Allows setting an offset for the grid lines.
  70818. */
  70819. gridOffset: BABYLON.Vector3;
  70820. /**
  70821. * The frequency of thicker lines.
  70822. */
  70823. majorUnitFrequency: number;
  70824. /**
  70825. * The visibility of minor units in the grid.
  70826. */
  70827. minorUnitVisibility: number;
  70828. /**
  70829. * The grid opacity outside of the lines.
  70830. */
  70831. opacity: number;
  70832. /**
  70833. * Determine RBG output is premultiplied by alpha value.
  70834. */
  70835. preMultiplyAlpha: boolean;
  70836. private _opacityTexture;
  70837. opacityTexture: BABYLON.BaseTexture;
  70838. private _gridControl;
  70839. private _renderId;
  70840. /**
  70841. * constructor
  70842. * @param name The name given to the material in order to identify it afterwards.
  70843. * @param scene The scene the material is used in.
  70844. */
  70845. constructor(name: string, scene: BABYLON.Scene);
  70846. /**
  70847. * Returns wehter or not the grid requires alpha blending.
  70848. */
  70849. needAlphaBlending(): boolean;
  70850. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70851. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70852. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70853. /**
  70854. * Dispose the material and its associated resources.
  70855. * @param forceDisposeEffect will also dispose the used effect when true
  70856. */
  70857. dispose(forceDisposeEffect?: boolean): void;
  70858. clone(name: string): GridMaterial;
  70859. serialize(): any;
  70860. getClassName(): string;
  70861. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70862. }
  70863. }
  70864. declare module BABYLON {
  70865. /** @hidden */
  70866. export var lavaPixelShader: {
  70867. name: string;
  70868. shader: string;
  70869. };
  70870. }
  70871. declare module BABYLON {
  70872. /** @hidden */
  70873. export var lavaVertexShader: {
  70874. name: string;
  70875. shader: string;
  70876. };
  70877. }
  70878. declare module BABYLON {
  70879. export class LavaMaterial extends BABYLON.PushMaterial {
  70880. private _diffuseTexture;
  70881. diffuseTexture: BABYLON.BaseTexture;
  70882. noiseTexture: BABYLON.BaseTexture;
  70883. fogColor: BABYLON.Color3;
  70884. speed: number;
  70885. movingSpeed: number;
  70886. lowFrequencySpeed: number;
  70887. fogDensity: number;
  70888. private _lastTime;
  70889. diffuseColor: BABYLON.Color3;
  70890. private _disableLighting;
  70891. disableLighting: boolean;
  70892. private _unlit;
  70893. unlit: boolean;
  70894. private _maxSimultaneousLights;
  70895. maxSimultaneousLights: number;
  70896. private _scaledDiffuse;
  70897. private _renderId;
  70898. constructor(name: string, scene: BABYLON.Scene);
  70899. needAlphaBlending(): boolean;
  70900. needAlphaTesting(): boolean;
  70901. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70902. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70903. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70904. getAnimatables(): BABYLON.IAnimatable[];
  70905. getActiveTextures(): BABYLON.BaseTexture[];
  70906. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70907. dispose(forceDisposeEffect?: boolean): void;
  70908. clone(name: string): LavaMaterial;
  70909. serialize(): any;
  70910. getClassName(): string;
  70911. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70912. }
  70913. }
  70914. declare module BABYLON {
  70915. /** @hidden */
  70916. export var mixPixelShader: {
  70917. name: string;
  70918. shader: string;
  70919. };
  70920. }
  70921. declare module BABYLON {
  70922. /** @hidden */
  70923. export var mixVertexShader: {
  70924. name: string;
  70925. shader: string;
  70926. };
  70927. }
  70928. declare module BABYLON {
  70929. export class MixMaterial extends BABYLON.PushMaterial {
  70930. /**
  70931. * Mix textures
  70932. */
  70933. private _mixTexture1;
  70934. mixTexture1: BABYLON.BaseTexture;
  70935. private _mixTexture2;
  70936. mixTexture2: BABYLON.BaseTexture;
  70937. /**
  70938. * Diffuse textures
  70939. */
  70940. private _diffuseTexture1;
  70941. diffuseTexture1: BABYLON.Texture;
  70942. private _diffuseTexture2;
  70943. diffuseTexture2: BABYLON.Texture;
  70944. private _diffuseTexture3;
  70945. diffuseTexture3: BABYLON.Texture;
  70946. private _diffuseTexture4;
  70947. diffuseTexture4: BABYLON.Texture;
  70948. private _diffuseTexture5;
  70949. diffuseTexture5: BABYLON.Texture;
  70950. private _diffuseTexture6;
  70951. diffuseTexture6: BABYLON.Texture;
  70952. private _diffuseTexture7;
  70953. diffuseTexture7: BABYLON.Texture;
  70954. private _diffuseTexture8;
  70955. diffuseTexture8: BABYLON.Texture;
  70956. /**
  70957. * Uniforms
  70958. */
  70959. diffuseColor: BABYLON.Color3;
  70960. specularColor: BABYLON.Color3;
  70961. specularPower: number;
  70962. private _disableLighting;
  70963. disableLighting: boolean;
  70964. private _maxSimultaneousLights;
  70965. maxSimultaneousLights: number;
  70966. private _renderId;
  70967. constructor(name: string, scene: BABYLON.Scene);
  70968. needAlphaBlending(): boolean;
  70969. needAlphaTesting(): boolean;
  70970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70971. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70972. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70973. getAnimatables(): BABYLON.IAnimatable[];
  70974. getActiveTextures(): BABYLON.BaseTexture[];
  70975. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70976. dispose(forceDisposeEffect?: boolean): void;
  70977. clone(name: string): MixMaterial;
  70978. serialize(): any;
  70979. getClassName(): string;
  70980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70981. }
  70982. }
  70983. declare module BABYLON {
  70984. /** @hidden */
  70985. export var normalPixelShader: {
  70986. name: string;
  70987. shader: string;
  70988. };
  70989. }
  70990. declare module BABYLON {
  70991. /** @hidden */
  70992. export var normalVertexShader: {
  70993. name: string;
  70994. shader: string;
  70995. };
  70996. }
  70997. declare module BABYLON {
  70998. export class NormalMaterial extends BABYLON.PushMaterial {
  70999. private _diffuseTexture;
  71000. diffuseTexture: BABYLON.BaseTexture;
  71001. diffuseColor: BABYLON.Color3;
  71002. private _disableLighting;
  71003. disableLighting: boolean;
  71004. private _maxSimultaneousLights;
  71005. maxSimultaneousLights: number;
  71006. private _renderId;
  71007. constructor(name: string, scene: BABYLON.Scene);
  71008. needAlphaBlending(): boolean;
  71009. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71010. needAlphaTesting(): boolean;
  71011. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71012. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71013. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71014. getAnimatables(): BABYLON.IAnimatable[];
  71015. getActiveTextures(): BABYLON.BaseTexture[];
  71016. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71017. dispose(forceDisposeEffect?: boolean): void;
  71018. clone(name: string): NormalMaterial;
  71019. serialize(): any;
  71020. getClassName(): string;
  71021. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71022. }
  71023. }
  71024. declare module BABYLON {
  71025. /** @hidden */
  71026. export var shadowOnlyPixelShader: {
  71027. name: string;
  71028. shader: string;
  71029. };
  71030. }
  71031. declare module BABYLON {
  71032. /** @hidden */
  71033. export var shadowOnlyVertexShader: {
  71034. name: string;
  71035. shader: string;
  71036. };
  71037. }
  71038. declare module BABYLON {
  71039. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71040. private _renderId;
  71041. private _activeLight;
  71042. constructor(name: string, scene: BABYLON.Scene);
  71043. shadowColor: BABYLON.Color3;
  71044. needAlphaBlending(): boolean;
  71045. needAlphaTesting(): boolean;
  71046. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71047. activeLight: BABYLON.IShadowLight;
  71048. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71049. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71050. clone(name: string): ShadowOnlyMaterial;
  71051. serialize(): any;
  71052. getClassName(): string;
  71053. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71054. }
  71055. }
  71056. declare module BABYLON {
  71057. /** @hidden */
  71058. export var simplePixelShader: {
  71059. name: string;
  71060. shader: string;
  71061. };
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var simpleVertexShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. export class SimpleMaterial extends BABYLON.PushMaterial {
  71072. private _diffuseTexture;
  71073. diffuseTexture: BABYLON.BaseTexture;
  71074. diffuseColor: BABYLON.Color3;
  71075. private _disableLighting;
  71076. disableLighting: boolean;
  71077. private _maxSimultaneousLights;
  71078. maxSimultaneousLights: number;
  71079. private _renderId;
  71080. constructor(name: string, scene: BABYLON.Scene);
  71081. needAlphaBlending(): boolean;
  71082. needAlphaTesting(): boolean;
  71083. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71084. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71086. getAnimatables(): BABYLON.IAnimatable[];
  71087. getActiveTextures(): BABYLON.BaseTexture[];
  71088. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71089. dispose(forceDisposeEffect?: boolean): void;
  71090. clone(name: string): SimpleMaterial;
  71091. serialize(): any;
  71092. getClassName(): string;
  71093. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71094. }
  71095. }
  71096. declare module BABYLON {
  71097. /** @hidden */
  71098. export var skyPixelShader: {
  71099. name: string;
  71100. shader: string;
  71101. };
  71102. }
  71103. declare module BABYLON {
  71104. /** @hidden */
  71105. export var skyVertexShader: {
  71106. name: string;
  71107. shader: string;
  71108. };
  71109. }
  71110. declare module BABYLON {
  71111. /**
  71112. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71113. * @see https://doc.babylonjs.com/extensions/sky
  71114. */
  71115. export class SkyMaterial extends BABYLON.PushMaterial {
  71116. /**
  71117. * Defines the overall luminance of sky in interval ]0, 1[.
  71118. */
  71119. luminance: number;
  71120. /**
  71121. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71122. */
  71123. turbidity: number;
  71124. /**
  71125. * Defines the sky appearance (light intensity).
  71126. */
  71127. rayleigh: number;
  71128. /**
  71129. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71130. */
  71131. mieCoefficient: number;
  71132. /**
  71133. * Defines the amount of haze particles following the Mie scattering theory.
  71134. */
  71135. mieDirectionalG: number;
  71136. /**
  71137. * Defines the distance of the sun according to the active scene camera.
  71138. */
  71139. distance: number;
  71140. /**
  71141. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71142. * "inclined".
  71143. */
  71144. inclination: number;
  71145. /**
  71146. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71147. * an object direction and a reference direction.
  71148. */
  71149. azimuth: number;
  71150. /**
  71151. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71152. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71153. */
  71154. sunPosition: BABYLON.Vector3;
  71155. /**
  71156. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71157. * .sunPosition property.
  71158. */
  71159. useSunPosition: boolean;
  71160. /**
  71161. * Defines an offset vector used to get a horizon offset.
  71162. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71163. */
  71164. cameraOffset: BABYLON.Vector3;
  71165. private _cameraPosition;
  71166. private _renderId;
  71167. /**
  71168. * Instantiates a new sky material.
  71169. * This material allows to create dynamic and texture free
  71170. * effects for skyboxes by taking care of the atmosphere state.
  71171. * @see https://doc.babylonjs.com/extensions/sky
  71172. * @param name Define the name of the material in the scene
  71173. * @param scene Define the scene the material belong to
  71174. */
  71175. constructor(name: string, scene: BABYLON.Scene);
  71176. /**
  71177. * Specifies if the material will require alpha blending
  71178. * @returns a boolean specifying if alpha blending is needed
  71179. */
  71180. needAlphaBlending(): boolean;
  71181. /**
  71182. * Specifies if this material should be rendered in alpha test mode
  71183. * @returns false as the sky material doesn't need alpha testing.
  71184. */
  71185. needAlphaTesting(): boolean;
  71186. /**
  71187. * Get the texture used for alpha test purpose.
  71188. * @returns null as the sky material has no texture.
  71189. */
  71190. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71191. /**
  71192. * Get if the submesh is ready to be used and all its information available.
  71193. * Child classes can use it to update shaders
  71194. * @param mesh defines the mesh to check
  71195. * @param subMesh defines which submesh to check
  71196. * @param useInstances specifies that instances should be used
  71197. * @returns a boolean indicating that the submesh is ready or not
  71198. */
  71199. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71200. /**
  71201. * Binds the submesh to this material by preparing the effect and shader to draw
  71202. * @param world defines the world transformation matrix
  71203. * @param mesh defines the mesh containing the submesh
  71204. * @param subMesh defines the submesh to bind the material to
  71205. */
  71206. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71207. /**
  71208. * Get the list of animatables in the material.
  71209. * @returns the list of animatables object used in the material
  71210. */
  71211. getAnimatables(): BABYLON.IAnimatable[];
  71212. /**
  71213. * Disposes the material
  71214. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71215. */
  71216. dispose(forceDisposeEffect?: boolean): void;
  71217. /**
  71218. * Makes a duplicate of the material, and gives it a new name
  71219. * @param name defines the new name for the duplicated material
  71220. * @returns the cloned material
  71221. */
  71222. clone(name: string): SkyMaterial;
  71223. /**
  71224. * Serializes this material in a JSON representation
  71225. * @returns the serialized material object
  71226. */
  71227. serialize(): any;
  71228. /**
  71229. * Gets the current class name of the material e.g. "SkyMaterial"
  71230. * Mainly use in serialization.
  71231. * @returns the class name
  71232. */
  71233. getClassName(): string;
  71234. /**
  71235. * Creates a sky material from parsed material data
  71236. * @param source defines the JSON representation of the material
  71237. * @param scene defines the hosting scene
  71238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71239. * @returns a new sky material
  71240. */
  71241. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71242. }
  71243. }
  71244. declare module BABYLON {
  71245. /** @hidden */
  71246. export var terrainPixelShader: {
  71247. name: string;
  71248. shader: string;
  71249. };
  71250. }
  71251. declare module BABYLON {
  71252. /** @hidden */
  71253. export var terrainVertexShader: {
  71254. name: string;
  71255. shader: string;
  71256. };
  71257. }
  71258. declare module BABYLON {
  71259. export class TerrainMaterial extends BABYLON.PushMaterial {
  71260. private _mixTexture;
  71261. mixTexture: BABYLON.BaseTexture;
  71262. private _diffuseTexture1;
  71263. diffuseTexture1: BABYLON.Texture;
  71264. private _diffuseTexture2;
  71265. diffuseTexture2: BABYLON.Texture;
  71266. private _diffuseTexture3;
  71267. diffuseTexture3: BABYLON.Texture;
  71268. private _bumpTexture1;
  71269. bumpTexture1: BABYLON.Texture;
  71270. private _bumpTexture2;
  71271. bumpTexture2: BABYLON.Texture;
  71272. private _bumpTexture3;
  71273. bumpTexture3: BABYLON.Texture;
  71274. diffuseColor: BABYLON.Color3;
  71275. specularColor: BABYLON.Color3;
  71276. specularPower: number;
  71277. private _disableLighting;
  71278. disableLighting: boolean;
  71279. private _maxSimultaneousLights;
  71280. maxSimultaneousLights: number;
  71281. private _renderId;
  71282. constructor(name: string, scene: BABYLON.Scene);
  71283. needAlphaBlending(): boolean;
  71284. needAlphaTesting(): boolean;
  71285. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71286. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71287. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71288. getAnimatables(): BABYLON.IAnimatable[];
  71289. getActiveTextures(): BABYLON.BaseTexture[];
  71290. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71291. dispose(forceDisposeEffect?: boolean): void;
  71292. clone(name: string): TerrainMaterial;
  71293. serialize(): any;
  71294. getClassName(): string;
  71295. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71296. }
  71297. }
  71298. declare module BABYLON {
  71299. /** @hidden */
  71300. export var triplanarPixelShader: {
  71301. name: string;
  71302. shader: string;
  71303. };
  71304. }
  71305. declare module BABYLON {
  71306. /** @hidden */
  71307. export var triplanarVertexShader: {
  71308. name: string;
  71309. shader: string;
  71310. };
  71311. }
  71312. declare module BABYLON {
  71313. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71314. mixTexture: BABYLON.BaseTexture;
  71315. private _diffuseTextureX;
  71316. diffuseTextureX: BABYLON.BaseTexture;
  71317. private _diffuseTextureY;
  71318. diffuseTextureY: BABYLON.BaseTexture;
  71319. private _diffuseTextureZ;
  71320. diffuseTextureZ: BABYLON.BaseTexture;
  71321. private _normalTextureX;
  71322. normalTextureX: BABYLON.BaseTexture;
  71323. private _normalTextureY;
  71324. normalTextureY: BABYLON.BaseTexture;
  71325. private _normalTextureZ;
  71326. normalTextureZ: BABYLON.BaseTexture;
  71327. tileSize: number;
  71328. diffuseColor: BABYLON.Color3;
  71329. specularColor: BABYLON.Color3;
  71330. specularPower: number;
  71331. private _disableLighting;
  71332. disableLighting: boolean;
  71333. private _maxSimultaneousLights;
  71334. maxSimultaneousLights: number;
  71335. private _renderId;
  71336. constructor(name: string, scene: BABYLON.Scene);
  71337. needAlphaBlending(): boolean;
  71338. needAlphaTesting(): boolean;
  71339. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71340. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71341. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71342. getAnimatables(): BABYLON.IAnimatable[];
  71343. getActiveTextures(): BABYLON.BaseTexture[];
  71344. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71345. dispose(forceDisposeEffect?: boolean): void;
  71346. clone(name: string): TriPlanarMaterial;
  71347. serialize(): any;
  71348. getClassName(): string;
  71349. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71350. }
  71351. }
  71352. declare module BABYLON {
  71353. /** @hidden */
  71354. export var waterPixelShader: {
  71355. name: string;
  71356. shader: string;
  71357. };
  71358. }
  71359. declare module BABYLON {
  71360. /** @hidden */
  71361. export var waterVertexShader: {
  71362. name: string;
  71363. shader: string;
  71364. };
  71365. }
  71366. declare module BABYLON {
  71367. export class WaterMaterial extends BABYLON.PushMaterial {
  71368. renderTargetSize: BABYLON.Vector2;
  71369. private _bumpTexture;
  71370. bumpTexture: BABYLON.BaseTexture;
  71371. diffuseColor: BABYLON.Color3;
  71372. specularColor: BABYLON.Color3;
  71373. specularPower: number;
  71374. private _disableLighting;
  71375. disableLighting: boolean;
  71376. private _maxSimultaneousLights;
  71377. maxSimultaneousLights: number;
  71378. /**
  71379. * @param {number}: Represents the wind force
  71380. */
  71381. windForce: number;
  71382. /**
  71383. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71384. */
  71385. windDirection: BABYLON.Vector2;
  71386. /**
  71387. * @param {number}: Wave height, represents the height of the waves
  71388. */
  71389. waveHeight: number;
  71390. /**
  71391. * @param {number}: Bump height, represents the bump height related to the bump map
  71392. */
  71393. bumpHeight: number;
  71394. /**
  71395. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71396. */
  71397. private _bumpSuperimpose;
  71398. bumpSuperimpose: boolean;
  71399. /**
  71400. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71401. */
  71402. private _fresnelSeparate;
  71403. fresnelSeparate: boolean;
  71404. /**
  71405. * @param {boolean}: bump Waves modify the reflection.
  71406. */
  71407. private _bumpAffectsReflection;
  71408. bumpAffectsReflection: boolean;
  71409. /**
  71410. * @param {number}: The water color blended with the refraction (near)
  71411. */
  71412. waterColor: BABYLON.Color3;
  71413. /**
  71414. * @param {number}: The blend factor related to the water color
  71415. */
  71416. colorBlendFactor: number;
  71417. /**
  71418. * @param {number}: The water color blended with the reflection (far)
  71419. */
  71420. waterColor2: BABYLON.Color3;
  71421. /**
  71422. * @param {number}: The blend factor related to the water color (reflection, far)
  71423. */
  71424. colorBlendFactor2: number;
  71425. /**
  71426. * @param {number}: Represents the maximum length of a wave
  71427. */
  71428. waveLength: number;
  71429. /**
  71430. * @param {number}: Defines the waves speed
  71431. */
  71432. waveSpeed: number;
  71433. /**
  71434. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71435. * will avoid calculating useless pixels in the pixel shader of the water material.
  71436. */
  71437. disableClipPlane: boolean;
  71438. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71439. private _mesh;
  71440. private _refractionRTT;
  71441. private _reflectionRTT;
  71442. private _reflectionTransform;
  71443. private _lastTime;
  71444. private _lastDeltaTime;
  71445. private _renderId;
  71446. private _useLogarithmicDepth;
  71447. private _waitingRenderList;
  71448. private _imageProcessingConfiguration;
  71449. private _imageProcessingObserver;
  71450. /**
  71451. * Gets a boolean indicating that current material needs to register RTT
  71452. */
  71453. readonly hasRenderTargetTextures: boolean;
  71454. /**
  71455. * Constructor
  71456. */
  71457. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71458. useLogarithmicDepth: boolean;
  71459. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71460. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71461. addToRenderList(node: any): void;
  71462. enableRenderTargets(enable: boolean): void;
  71463. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71464. readonly renderTargetsEnabled: boolean;
  71465. needAlphaBlending(): boolean;
  71466. needAlphaTesting(): boolean;
  71467. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71468. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71469. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71470. private _createRenderTargets;
  71471. getAnimatables(): BABYLON.IAnimatable[];
  71472. getActiveTextures(): BABYLON.BaseTexture[];
  71473. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71474. dispose(forceDisposeEffect?: boolean): void;
  71475. clone(name: string): WaterMaterial;
  71476. serialize(): any;
  71477. getClassName(): string;
  71478. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71479. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71480. }
  71481. }
  71482. declare module BABYLON {
  71483. /** @hidden */
  71484. export var asciiartPixelShader: {
  71485. name: string;
  71486. shader: string;
  71487. };
  71488. }
  71489. declare module BABYLON {
  71490. /**
  71491. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71492. *
  71493. * It basically takes care rendering the font front the given font size to a texture.
  71494. * This is used later on in the postprocess.
  71495. */
  71496. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71497. private _font;
  71498. private _text;
  71499. private _charSize;
  71500. /**
  71501. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71502. */
  71503. readonly charSize: number;
  71504. /**
  71505. * Create a new instance of the Ascii Art FontTexture class
  71506. * @param name the name of the texture
  71507. * @param font the font to use, use the W3C CSS notation
  71508. * @param text the caracter set to use in the rendering.
  71509. * @param scene the scene that owns the texture
  71510. */
  71511. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71512. /**
  71513. * Gets the max char width of a font.
  71514. * @param font the font to use, use the W3C CSS notation
  71515. * @return the max char width
  71516. */
  71517. private getFontWidth;
  71518. /**
  71519. * Gets the max char height of a font.
  71520. * @param font the font to use, use the W3C CSS notation
  71521. * @return the max char height
  71522. */
  71523. private getFontHeight;
  71524. /**
  71525. * Clones the current AsciiArtTexture.
  71526. * @return the clone of the texture.
  71527. */
  71528. clone(): AsciiArtFontTexture;
  71529. /**
  71530. * Parses a json object representing the texture and returns an instance of it.
  71531. * @param source the source JSON representation
  71532. * @param scene the scene to create the texture for
  71533. * @return the parsed texture
  71534. */
  71535. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71536. }
  71537. /**
  71538. * Option available in the Ascii Art Post Process.
  71539. */
  71540. export interface IAsciiArtPostProcessOptions {
  71541. /**
  71542. * The font to use following the w3c font definition.
  71543. */
  71544. font?: string;
  71545. /**
  71546. * The character set to use in the postprocess.
  71547. */
  71548. characterSet?: string;
  71549. /**
  71550. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71551. * This number is defined between 0 and 1;
  71552. */
  71553. mixToTile?: number;
  71554. /**
  71555. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71556. * This number is defined between 0 and 1;
  71557. */
  71558. mixToNormal?: number;
  71559. }
  71560. /**
  71561. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71562. *
  71563. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71564. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71565. */
  71566. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71567. /**
  71568. * The font texture used to render the char in the post process.
  71569. */
  71570. private _asciiArtFontTexture;
  71571. /**
  71572. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71573. * This number is defined between 0 and 1;
  71574. */
  71575. mixToTile: number;
  71576. /**
  71577. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71578. * This number is defined between 0 and 1;
  71579. */
  71580. mixToNormal: number;
  71581. /**
  71582. * Instantiates a new Ascii Art Post Process.
  71583. * @param name the name to give to the postprocess
  71584. * @camera the camera to apply the post process to.
  71585. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71586. */
  71587. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71588. }
  71589. }
  71590. declare module BABYLON {
  71591. /** @hidden */
  71592. export var digitalrainPixelShader: {
  71593. name: string;
  71594. shader: string;
  71595. };
  71596. }
  71597. declare module BABYLON {
  71598. /**
  71599. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71600. *
  71601. * It basically takes care rendering the font front the given font size to a texture.
  71602. * This is used later on in the postprocess.
  71603. */
  71604. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71605. private _font;
  71606. private _text;
  71607. private _charSize;
  71608. /**
  71609. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71610. */
  71611. readonly charSize: number;
  71612. /**
  71613. * Create a new instance of the Digital Rain FontTexture class
  71614. * @param name the name of the texture
  71615. * @param font the font to use, use the W3C CSS notation
  71616. * @param text the caracter set to use in the rendering.
  71617. * @param scene the scene that owns the texture
  71618. */
  71619. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71620. /**
  71621. * Gets the max char width of a font.
  71622. * @param font the font to use, use the W3C CSS notation
  71623. * @return the max char width
  71624. */
  71625. private getFontWidth;
  71626. /**
  71627. * Gets the max char height of a font.
  71628. * @param font the font to use, use the W3C CSS notation
  71629. * @return the max char height
  71630. */
  71631. private getFontHeight;
  71632. /**
  71633. * Clones the current DigitalRainFontTexture.
  71634. * @return the clone of the texture.
  71635. */
  71636. clone(): DigitalRainFontTexture;
  71637. /**
  71638. * Parses a json object representing the texture and returns an instance of it.
  71639. * @param source the source JSON representation
  71640. * @param scene the scene to create the texture for
  71641. * @return the parsed texture
  71642. */
  71643. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71644. }
  71645. /**
  71646. * Option available in the Digital Rain Post Process.
  71647. */
  71648. export interface IDigitalRainPostProcessOptions {
  71649. /**
  71650. * The font to use following the w3c font definition.
  71651. */
  71652. font?: string;
  71653. /**
  71654. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71655. * This number is defined between 0 and 1;
  71656. */
  71657. mixToTile?: number;
  71658. /**
  71659. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71660. * This number is defined between 0 and 1;
  71661. */
  71662. mixToNormal?: number;
  71663. }
  71664. /**
  71665. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71666. *
  71667. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71668. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71669. */
  71670. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71671. /**
  71672. * The font texture used to render the char in the post process.
  71673. */
  71674. private _digitalRainFontTexture;
  71675. /**
  71676. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71677. * This number is defined between 0 and 1;
  71678. */
  71679. mixToTile: number;
  71680. /**
  71681. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71682. * This number is defined between 0 and 1;
  71683. */
  71684. mixToNormal: number;
  71685. /**
  71686. * Instantiates a new Digital Rain Post Process.
  71687. * @param name the name to give to the postprocess
  71688. * @camera the camera to apply the post process to.
  71689. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71690. */
  71691. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71692. }
  71693. }
  71694. declare module BABYLON {
  71695. /** @hidden */
  71696. export var oceanPostProcessPixelShader: {
  71697. name: string;
  71698. shader: string;
  71699. };
  71700. }
  71701. declare module BABYLON {
  71702. /**
  71703. * Option available in the Ocean Post Process.
  71704. */
  71705. export interface IOceanPostProcessOptions {
  71706. /**
  71707. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71708. */
  71709. reflectionSize?: number | {
  71710. width: number;
  71711. height: number;
  71712. } | {
  71713. ratio: number;
  71714. };
  71715. /**
  71716. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71717. */
  71718. refractionSize?: number | {
  71719. width: number;
  71720. height: number;
  71721. } | {
  71722. ratio: number;
  71723. };
  71724. }
  71725. /**
  71726. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71727. *
  71728. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71729. * Example usage:
  71730. * var pp = new OceanPostProcess("myOcean", camera);
  71731. * pp.reflectionEnabled = true;
  71732. * pp.refractionEnabled = true;
  71733. */
  71734. export class OceanPostProcess extends BABYLON.PostProcess {
  71735. /**
  71736. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71737. */
  71738. /**
  71739. * Sets weither or not the real-time reflection is enabled on the ocean.
  71740. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71741. */
  71742. reflectionEnabled: boolean;
  71743. /**
  71744. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71745. */
  71746. /**
  71747. * Sets weither or not the real-time refraction is enabled on the ocean.
  71748. * Is set to true, the refraction render target texture will be used as refraction texture.
  71749. */
  71750. refractionEnabled: boolean;
  71751. /**
  71752. * Gets wether or not the post-processes is supported by the running hardware.
  71753. * This requires draw buffer supports.
  71754. */
  71755. readonly isSupported: boolean;
  71756. /**
  71757. * This is the reflection mirror texture used to display reflections on the ocean.
  71758. * By default, render list is empty.
  71759. */
  71760. reflectionTexture: BABYLON.MirrorTexture;
  71761. /**
  71762. * This is the refraction render target texture used to display refraction on the ocean.
  71763. * By default, render list is empty.
  71764. */
  71765. refractionTexture: BABYLON.RenderTargetTexture;
  71766. private _time;
  71767. private _cameraRotation;
  71768. private _cameraViewMatrix;
  71769. private _reflectionEnabled;
  71770. private _refractionEnabled;
  71771. private _geometryRenderer;
  71772. /**
  71773. * Instantiates a new Ocean Post Process.
  71774. * @param name the name to give to the postprocess.
  71775. * @camera the camera to apply the post process to.
  71776. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71777. */
  71778. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71779. /**
  71780. * Returns the appropriate defines according to the current configuration.
  71781. */
  71782. private _getDefines;
  71783. /**
  71784. * Computes the current camera rotation as the shader requires a camera rotation.
  71785. */
  71786. private _computeCameraRotation;
  71787. }
  71788. }
  71789. declare module BABYLON {
  71790. /** @hidden */
  71791. export var brickProceduralTexturePixelShader: {
  71792. name: string;
  71793. shader: string;
  71794. };
  71795. }
  71796. declare module BABYLON {
  71797. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71798. private _numberOfBricksHeight;
  71799. private _numberOfBricksWidth;
  71800. private _jointColor;
  71801. private _brickColor;
  71802. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71803. updateShaderUniforms(): void;
  71804. numberOfBricksHeight: number;
  71805. numberOfBricksWidth: number;
  71806. jointColor: BABYLON.Color3;
  71807. brickColor: BABYLON.Color3;
  71808. /**
  71809. * Serializes this brick procedural texture
  71810. * @returns a serialized brick procedural texture object
  71811. */
  71812. serialize(): any;
  71813. /**
  71814. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71815. * @param parsedTexture defines parsed texture data
  71816. * @param scene defines the current scene
  71817. * @param rootUrl defines the root URL containing brick procedural texture information
  71818. * @returns a parsed Brick Procedural BABYLON.Texture
  71819. */
  71820. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71821. }
  71822. }
  71823. declare module BABYLON {
  71824. /** @hidden */
  71825. export var cloudProceduralTexturePixelShader: {
  71826. name: string;
  71827. shader: string;
  71828. };
  71829. }
  71830. declare module BABYLON {
  71831. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71832. private _skyColor;
  71833. private _cloudColor;
  71834. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71835. updateShaderUniforms(): void;
  71836. skyColor: BABYLON.Color4;
  71837. cloudColor: BABYLON.Color4;
  71838. /**
  71839. * Serializes this cloud procedural texture
  71840. * @returns a serialized cloud procedural texture object
  71841. */
  71842. serialize(): any;
  71843. /**
  71844. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71845. * @param parsedTexture defines parsed texture data
  71846. * @param scene defines the current scene
  71847. * @param rootUrl defines the root URL containing cloud procedural texture information
  71848. * @returns a parsed Cloud Procedural BABYLON.Texture
  71849. */
  71850. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71851. }
  71852. }
  71853. declare module BABYLON {
  71854. /** @hidden */
  71855. export var fireProceduralTexturePixelShader: {
  71856. name: string;
  71857. shader: string;
  71858. };
  71859. }
  71860. declare module BABYLON {
  71861. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71862. private _time;
  71863. private _speed;
  71864. private _autoGenerateTime;
  71865. private _fireColors;
  71866. private _alphaThreshold;
  71867. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71868. updateShaderUniforms(): void;
  71869. render(useCameraPostProcess?: boolean): void;
  71870. static readonly PurpleFireColors: BABYLON.Color3[];
  71871. static readonly GreenFireColors: BABYLON.Color3[];
  71872. static readonly RedFireColors: BABYLON.Color3[];
  71873. static readonly BlueFireColors: BABYLON.Color3[];
  71874. autoGenerateTime: boolean;
  71875. fireColors: BABYLON.Color3[];
  71876. time: number;
  71877. speed: BABYLON.Vector2;
  71878. alphaThreshold: number;
  71879. /**
  71880. * Serializes this fire procedural texture
  71881. * @returns a serialized fire procedural texture object
  71882. */
  71883. serialize(): any;
  71884. /**
  71885. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71886. * @param parsedTexture defines parsed texture data
  71887. * @param scene defines the current scene
  71888. * @param rootUrl defines the root URL containing fire procedural texture information
  71889. * @returns a parsed Fire Procedural BABYLON.Texture
  71890. */
  71891. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71892. }
  71893. }
  71894. declare module BABYLON {
  71895. /** @hidden */
  71896. export var grassProceduralTexturePixelShader: {
  71897. name: string;
  71898. shader: string;
  71899. };
  71900. }
  71901. declare module BABYLON {
  71902. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71903. private _grassColors;
  71904. private _groundColor;
  71905. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71906. updateShaderUniforms(): void;
  71907. grassColors: BABYLON.Color3[];
  71908. groundColor: BABYLON.Color3;
  71909. /**
  71910. * Serializes this grass procedural texture
  71911. * @returns a serialized grass procedural texture object
  71912. */
  71913. serialize(): any;
  71914. /**
  71915. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71916. * @param parsedTexture defines parsed texture data
  71917. * @param scene defines the current scene
  71918. * @param rootUrl defines the root URL containing grass procedural texture information
  71919. * @returns a parsed Grass Procedural BABYLON.Texture
  71920. */
  71921. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71922. }
  71923. }
  71924. declare module BABYLON {
  71925. /** @hidden */
  71926. export var marbleProceduralTexturePixelShader: {
  71927. name: string;
  71928. shader: string;
  71929. };
  71930. }
  71931. declare module BABYLON {
  71932. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71933. private _numberOfTilesHeight;
  71934. private _numberOfTilesWidth;
  71935. private _amplitude;
  71936. private _jointColor;
  71937. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71938. updateShaderUniforms(): void;
  71939. numberOfTilesHeight: number;
  71940. amplitude: number;
  71941. numberOfTilesWidth: number;
  71942. jointColor: BABYLON.Color3;
  71943. /**
  71944. * Serializes this marble procedural texture
  71945. * @returns a serialized marble procedural texture object
  71946. */
  71947. serialize(): any;
  71948. /**
  71949. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71950. * @param parsedTexture defines parsed texture data
  71951. * @param scene defines the current scene
  71952. * @param rootUrl defines the root URL containing marble procedural texture information
  71953. * @returns a parsed Marble Procedural BABYLON.Texture
  71954. */
  71955. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71956. }
  71957. }
  71958. declare module BABYLON {
  71959. /** @hidden */
  71960. export var normalMapProceduralTexturePixelShader: {
  71961. name: string;
  71962. shader: string;
  71963. };
  71964. }
  71965. declare module BABYLON {
  71966. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71967. private _baseTexture;
  71968. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71969. updateShaderUniforms(): void;
  71970. render(useCameraPostProcess?: boolean): void;
  71971. resize(size: any, generateMipMaps: any): void;
  71972. baseTexture: BABYLON.Texture;
  71973. /**
  71974. * Serializes this normal map procedural texture
  71975. * @returns a serialized normal map procedural texture object
  71976. */
  71977. serialize(): any;
  71978. /**
  71979. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71980. * @param parsedTexture defines parsed texture data
  71981. * @param scene defines the current scene
  71982. * @param rootUrl defines the root URL containing normal map procedural texture information
  71983. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71984. */
  71985. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71986. }
  71987. }
  71988. declare module BABYLON {
  71989. /** @hidden */
  71990. export var perlinNoiseProceduralTexturePixelShader: {
  71991. name: string;
  71992. shader: string;
  71993. };
  71994. }
  71995. declare module BABYLON {
  71996. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71997. time: number;
  71998. timeScale: number;
  71999. translationSpeed: number;
  72000. private _currentTranslation;
  72001. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72002. updateShaderUniforms(): void;
  72003. render(useCameraPostProcess?: boolean): void;
  72004. resize(size: any, generateMipMaps: any): void;
  72005. /**
  72006. * Serializes this perlin noise procedural texture
  72007. * @returns a serialized perlin noise procedural texture object
  72008. */
  72009. serialize(): any;
  72010. /**
  72011. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72012. * @param parsedTexture defines parsed texture data
  72013. * @param scene defines the current scene
  72014. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72015. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72016. */
  72017. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72018. }
  72019. }
  72020. declare module BABYLON {
  72021. /** @hidden */
  72022. export var roadProceduralTexturePixelShader: {
  72023. name: string;
  72024. shader: string;
  72025. };
  72026. }
  72027. declare module BABYLON {
  72028. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72029. private _roadColor;
  72030. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72031. updateShaderUniforms(): void;
  72032. roadColor: BABYLON.Color3;
  72033. /**
  72034. * Serializes this road procedural texture
  72035. * @returns a serialized road procedural texture object
  72036. */
  72037. serialize(): any;
  72038. /**
  72039. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72040. * @param parsedTexture defines parsed texture data
  72041. * @param scene defines the current scene
  72042. * @param rootUrl defines the root URL containing road procedural texture information
  72043. * @returns a parsed Road Procedural BABYLON.Texture
  72044. */
  72045. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72046. }
  72047. }
  72048. declare module BABYLON {
  72049. /** @hidden */
  72050. export var starfieldProceduralTexturePixelShader: {
  72051. name: string;
  72052. shader: string;
  72053. };
  72054. }
  72055. declare module BABYLON {
  72056. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72057. private _time;
  72058. private _alpha;
  72059. private _beta;
  72060. private _zoom;
  72061. private _formuparam;
  72062. private _stepsize;
  72063. private _tile;
  72064. private _brightness;
  72065. private _darkmatter;
  72066. private _distfading;
  72067. private _saturation;
  72068. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72069. updateShaderUniforms(): void;
  72070. time: number;
  72071. alpha: number;
  72072. beta: number;
  72073. formuparam: number;
  72074. stepsize: number;
  72075. zoom: number;
  72076. tile: number;
  72077. brightness: number;
  72078. darkmatter: number;
  72079. distfading: number;
  72080. saturation: number;
  72081. /**
  72082. * Serializes this starfield procedural texture
  72083. * @returns a serialized starfield procedural texture object
  72084. */
  72085. serialize(): any;
  72086. /**
  72087. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72088. * @param parsedTexture defines parsed texture data
  72089. * @param scene defines the current scene
  72090. * @param rootUrl defines the root URL containing startfield procedural texture information
  72091. * @returns a parsed Starfield Procedural BABYLON.Texture
  72092. */
  72093. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72094. }
  72095. }
  72096. declare module BABYLON {
  72097. /** @hidden */
  72098. export var woodProceduralTexturePixelShader: {
  72099. name: string;
  72100. shader: string;
  72101. };
  72102. }
  72103. declare module BABYLON {
  72104. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72105. private _ampScale;
  72106. private _woodColor;
  72107. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72108. updateShaderUniforms(): void;
  72109. ampScale: number;
  72110. woodColor: BABYLON.Color3;
  72111. /**
  72112. * Serializes this wood procedural texture
  72113. * @returns a serialized wood procedural texture object
  72114. */
  72115. serialize(): any;
  72116. /**
  72117. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72118. * @param parsedTexture defines parsed texture data
  72119. * @param scene defines the current scene
  72120. * @param rootUrl defines the root URL containing wood procedural texture information
  72121. * @returns a parsed Wood Procedural BABYLON.Texture
  72122. */
  72123. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72124. }
  72125. }